@lokalise/node-core 10.0.0-RC1 → 10.0.1
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 +16 -60
- package/dist/index.d.ts +12 -7
- package/dist/index.js +19 -14
- package/dist/index.js.map +1 -1
- package/dist/src/errors/InternalError.d.ts +1 -0
- package/dist/src/errors/InternalError.js +3 -1
- package/dist/src/errors/InternalError.js.map +1 -1
- package/dist/src/errors/PublicNonRecoverableError.d.ts +1 -0
- package/dist/src/errors/PublicNonRecoverableError.js +3 -1
- package/dist/src/errors/PublicNonRecoverableError.js.map +1 -1
- package/dist/src/errors/errorTypeGuards.d.ts +2 -2
- package/dist/src/errors/errorTypeGuards.js +5 -4
- package/dist/src/errors/errorTypeGuards.js.map +1 -1
- package/dist/src/errors/globalErrorHandler.d.ts +8 -7
- package/dist/src/errors/globalErrorHandler.js +15 -16
- package/dist/src/errors/globalErrorHandler.js.map +1 -1
- package/dist/src/errors/publicErrors.d.ts +5 -4
- package/dist/src/errors/publicErrors.js +15 -1
- package/dist/src/errors/publicErrors.js.map +1 -1
- package/dist/src/logging/commonLogger.d.ts +17 -0
- package/dist/src/logging/commonLogger.js +3 -0
- package/dist/src/logging/commonLogger.js.map +1 -0
- package/dist/src/logging/loggerConfigResolver.d.ts +3 -3
- package/dist/src/logging/loggerConfigResolver.js +16 -15
- package/dist/src/logging/loggerConfigResolver.js.map +1 -1
- package/dist/src/observability/observabilityTypes.d.ts +22 -0
- package/dist/src/observability/observabilityTypes.js +3 -0
- package/dist/src/observability/observabilityTypes.js.map +1 -0
- package/dist/src/utils/checksumUtils.d.ts +7 -0
- package/dist/src/utils/checksumUtils.js +38 -0
- package/dist/src/utils/checksumUtils.js.map +1 -0
- package/dist/src/utils/encryptionUtility.d.ts +21 -0
- package/dist/src/utils/encryptionUtility.js +58 -0
- package/dist/src/utils/encryptionUtility.js.map +1 -0
- package/dist/src/utils/hashUtils.d.ts +9 -0
- package/dist/src/utils/hashUtils.js +19 -0
- package/dist/src/utils/hashUtils.js.map +1 -0
- package/dist/src/utils/objectUtils.d.ts +17 -0
- package/dist/src/utils/objectUtils.js +58 -1
- package/dist/src/utils/objectUtils.js.map +1 -1
- package/dist/src/utils/streamUtils.d.ts +38 -0
- package/dist/src/utils/streamUtils.js +85 -0
- package/dist/src/utils/streamUtils.js.map +1 -0
- package/package.json +21 -26
- package/dist/index.cjs +0 -898
- package/dist/index.d.cts +0 -304
- package/dist/index.d.mts +0 -304
- package/dist/index.mjs +0 -848
- package/dist/src/config/ConfigScope.spec.d.ts +0 -1
- package/dist/src/config/ConfigScope.spec.js +0 -587
- package/dist/src/config/ConfigScope.spec.js.map +0 -1
- package/dist/src/config/configTransformers.spec.d.ts +0 -1
- package/dist/src/config/configTransformers.spec.js +0 -28
- package/dist/src/config/configTransformers.spec.js.map +0 -1
- package/dist/src/errors/PublicNonRecoverableError.spec.d.ts +0 -1
- package/dist/src/errors/PublicNonRecoverableError.spec.js +0 -13
- package/dist/src/errors/PublicNonRecoverableError.spec.js.map +0 -1
- package/dist/src/errors/ResponseStatusError.d.ts +0 -7
- package/dist/src/errors/ResponseStatusError.js +0 -27
- package/dist/src/errors/ResponseStatusError.js.map +0 -1
- package/dist/src/errors/errorTypeGuards.spec.d.ts +0 -1
- package/dist/src/errors/errorTypeGuards.spec.js +0 -23
- package/dist/src/errors/errorTypeGuards.spec.js.map +0 -1
- package/dist/src/errors/globalErrorHandler.spec.d.ts +0 -1
- package/dist/src/errors/globalErrorHandler.spec.js +0 -30
- package/dist/src/errors/globalErrorHandler.spec.js.map +0 -1
- package/dist/src/http/httpClient.d.ts +0 -50
- package/dist/src/http/httpClient.js +0 -180
- package/dist/src/http/httpClient.js.map +0 -1
- package/dist/src/http/httpClient.spec.d.ts +0 -1
- package/dist/src/http/httpClient.spec.js +0 -777
- package/dist/src/http/httpClient.spec.js.map +0 -1
- package/dist/src/http/mock-data/mockProduct1.json +0 -12
- package/dist/src/http/mock-data/mockProductsLimit3.json +0 -38
- package/dist/src/logging/loggerConfigResolver.spec.d.ts +0 -1
- package/dist/src/logging/loggerConfigResolver.spec.js +0 -34
- package/dist/src/logging/loggerConfigResolver.spec.js.map +0 -1
- package/dist/src/utils/arrayUtils.spec.d.ts +0 -1
- package/dist/src/utils/arrayUtils.spec.js +0 -60
- package/dist/src/utils/arrayUtils.spec.js.map +0 -1
- package/dist/src/utils/objectUtils.spec.d.ts +0 -1
- package/dist/src/utils/objectUtils.spec.js +0 -612
- package/dist/src/utils/objectUtils.spec.js.map +0 -1
- package/dist/src/utils/typeUtils.spec.d.ts +0 -1
- package/dist/src/utils/typeUtils.spec.js +0 -115
- package/dist/src/utils/typeUtils.spec.js.map +0 -1
- package/dist/src/utils/waitUtils.spec.d.ts +0 -1
- package/dist/src/utils/waitUtils.spec.js +0 -50
- package/dist/src/utils/waitUtils.spec.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -34
- package/dist/vitest.config.js.map +0 -1
package/README.md
CHANGED
|
@@ -12,66 +12,6 @@ See [docs](/docs) for further instructions on how to use.
|
|
|
12
12
|
|
|
13
13
|
## Overview
|
|
14
14
|
|
|
15
|
-
## HTTP Client
|
|
16
|
-
|
|
17
|
-
The library provides methods to implement the client side of HTTP protocols. Public methods available are:
|
|
18
|
-
|
|
19
|
-
- `buildClient()`, which returns a [Client](https://undici.nodejs.org/#/docs/api/Client) instance and should be called before any of the following methods with parameters:
|
|
20
|
-
- `baseUrl`;
|
|
21
|
-
- `clientOptions` – set of [ClientOptions](https://undici.nodejs.org/#/docs/api/Client?id=parameter-clientoptions) (optional). If none are provided, the following default options will be used to instantiate the client:
|
|
22
|
-
```ts
|
|
23
|
-
keepAliveMaxTimeout: 300_000,
|
|
24
|
-
keepAliveTimeout: 4000,
|
|
25
|
-
```
|
|
26
|
-
- `sendGet()`;
|
|
27
|
-
- `sendPost()`;
|
|
28
|
-
- `sendPut()`;
|
|
29
|
-
- `sendPutBinary()`;
|
|
30
|
-
- `sendDelete()`;
|
|
31
|
-
- `sendPatch()`.
|
|
32
|
-
|
|
33
|
-
All _send_ methods accept a type parameter and the following arguments:
|
|
34
|
-
|
|
35
|
-
- `client`, the return value of `buildClient()`;
|
|
36
|
-
- `path`;
|
|
37
|
-
- `options` – (optional). Possible values are:
|
|
38
|
-
|
|
39
|
-
- `headers`;
|
|
40
|
-
- `query`, query string params to be embedded in the request URL;
|
|
41
|
-
- `timeout`, the timeout after which a request will time out, in milliseconds;
|
|
42
|
-
- `throwOnError`;`
|
|
43
|
-
- `reqContext`;
|
|
44
|
-
- `safeParseJson`, used when the response content-type is `application/json`. If `true`, the response body will be parsed as JSON and a `ResponseError` will be thrown in case of syntax errors. If `false`, errors are not handled;
|
|
45
|
-
- `blobResponseBody`, used when the response body should be returned as Blob;
|
|
46
|
-
- `requestLabel`, this string will be returned together with any thrown or returned Error to provide additional context about what request was being executed when the error has happened;
|
|
47
|
-
- `disableKeepAlive`;`
|
|
48
|
-
- `retryConfig`, defined by:
|
|
49
|
-
- `maxAttempts`, the maximum number of times a request should be retried;
|
|
50
|
-
- `delayBetweenAttemptsInMsecs`;
|
|
51
|
-
- `statusCodesToRetry`, the status codes that trigger a retry;
|
|
52
|
-
- `retryOnTimeout`;
|
|
53
|
-
- `clientOptions`;
|
|
54
|
-
- `responseSchema`, used both for inferring the response type of the call, and also (if `validateResponse` is `true`) for validating the response structure;
|
|
55
|
-
- `validateResponse`;
|
|
56
|
-
|
|
57
|
-
The following options are applied by default:
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
validateResponse: true,
|
|
61
|
-
throwOnError: true,
|
|
62
|
-
timeout: 30000,
|
|
63
|
-
retryConfig: {
|
|
64
|
-
maxAttemps: 1,
|
|
65
|
-
delayBetweenAttemptsInMsecs: 0,
|
|
66
|
-
statusCodesToRetry: [],
|
|
67
|
-
retryOnTimeout: false,
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
Additionally, `sendPost()`, `sendPut()`, `sendPutBinary()`, and `sendPatch()` also accept a `body` parameter.
|
|
72
|
-
|
|
73
|
-
The response of any _send_ method will be resolved to always have `result` set, but only have `error` set in case something went wrong. See [Either](#either) for more information.
|
|
74
|
-
|
|
75
15
|
## Default Logging Configuration
|
|
76
16
|
|
|
77
17
|
The library provides methods to resolve the default logging configuration. Public methods available are:
|
|
@@ -231,3 +171,19 @@ const result = await waitAndRetry(
|
|
|
231
171
|
expect(result).toBe(false) // resolves to what the last attempt has returned
|
|
232
172
|
expect(someEventEmitter.emittedEvents.length).toBe(1)
|
|
233
173
|
```
|
|
174
|
+
|
|
175
|
+
## Encryption
|
|
176
|
+
|
|
177
|
+
- `EncryptionUtility` - small class for encrypting/decrypting using aes-256-gcm. Adapted from: https://github.com/MauriceButler/cryptr
|
|
178
|
+
|
|
179
|
+
## Hashing
|
|
180
|
+
|
|
181
|
+
- `HashUtils` - utils for hashing using sha256/sha512 algorithms
|
|
182
|
+
|
|
183
|
+
## Checksum
|
|
184
|
+
|
|
185
|
+
- `ChecksumUtils` - utils for insecure hashing using the MD5 algorithm
|
|
186
|
+
|
|
187
|
+
## Streams
|
|
188
|
+
|
|
189
|
+
- `StreamUtils` - utils for temporary persisting of streams for length calculation and reuse
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
export { sendPut, sendPutBinary, sendDelete, sendPatch, sendGet, sendPost, sendPostBinary, httpClient, buildClient, type RequestOptions, type Response, type HttpRequestContext, type ResponseSchema, } from './src/http/httpClient';
|
|
2
1
|
export { PublicNonRecoverableError, type PublicNonRecoverableErrorParams, } from './src/errors/PublicNonRecoverableError';
|
|
3
2
|
export { InternalError, type ErrorDetails, type InternalErrorParams, } from './src/errors/InternalError';
|
|
4
|
-
export {
|
|
5
|
-
export { isResponseStatusError } from './src/errors/errorTypeGuards';
|
|
3
|
+
export { isEntityGoneError } from './src/errors/errorTypeGuards';
|
|
6
4
|
export { ConfigScope } from './src/config/ConfigScope';
|
|
7
5
|
export { ensureClosingSlashTransformer } from './src/config/configTransformers';
|
|
8
6
|
export { createRangeValidator } from './src/config/configValidators';
|
|
9
7
|
export { type EnvValueValidator, type EnvValueTransformer, type AppConfig, type RedisConfig, } from './src/config/configTypes';
|
|
10
|
-
export { type Either, success, failure, isSuccess, isFailure } from './src/errors/either';
|
|
8
|
+
export { type Either, type DefiniteEither, success, failure, isSuccess, isFailure, } from './src/errors/either';
|
|
9
|
+
export { EncryptionUtility } from './src/utils/encryptionUtility';
|
|
11
10
|
export { chunk, callChunked, removeFalsy, removeNullish } from './src/utils/arrayUtils';
|
|
12
|
-
export { groupBy, groupByUnique, pick, pickWithoutUndefined, copyWithoutUndefined, isEmptyObject, convertDateFieldsToIsoString, deepClone, } from './src/utils/objectUtils';
|
|
13
|
-
export { isInternalError, isStandardizedError, isObject, isPublicNonRecoverableError, hasMessage, } from './src/utils/typeUtils';
|
|
11
|
+
export { groupBy, groupByPath, groupByUnique, pick, pickWithoutUndefined, copyWithoutUndefined, copyWithoutEmpty, isEmptyObject, convertDateFieldsToIsoString, deepClone, } from './src/utils/objectUtils';
|
|
12
|
+
export { isError, isInternalError, isStandardizedError, isObject, isPublicNonRecoverableError, hasMessage, } from './src/utils/typeUtils';
|
|
14
13
|
export { type StandardizedError } from './src/utils/typeUtils';
|
|
14
|
+
export { generateHash, HashAlgorithm, HashEncoding } from './src/utils/hashUtils';
|
|
15
15
|
export { resolveLoggerConfiguration, resolveMonorepoLoggerConfiguration, } from './src/logging/loggerConfigResolver';
|
|
16
16
|
export type { AppLoggerConfig, MonorepoAppLoggerConfig } from './src/logging/loggerConfigResolver';
|
|
17
|
+
export type { CommonLogger } from './src/logging/commonLogger';
|
|
17
18
|
export { type ErrorReport, type ErrorReporter, type ErrorResolver, } from './src/errors/errorReporterTypes';
|
|
18
19
|
export { executeAsyncAndHandleGlobalErrors, executeAndHandleGlobalErrors, executeSettleAllAndHandleGlobalErrors, globalLogger, resolveGlobalErrorLogObject, } from './src/errors/globalErrorHandler';
|
|
19
20
|
export { type MayOmit } from './src/common/may-omit';
|
|
20
21
|
export { type FreeformRecord } from './src/common/commonTypes';
|
|
21
|
-
export {
|
|
22
|
+
export { type ValidationError, type CommonErrorParams, type OptionalMessageErrorParams, RequestValidationError, AccessDeniedError, EntityNotFoundError, EntityGoneError, AuthFailedError, } from './src/errors/publicErrors';
|
|
22
23
|
export { waitAndRetry } from './src/utils/waitUtils';
|
|
24
|
+
export type { TransactionObservabilityManager } from './src/observability/observabilityTypes';
|
|
25
|
+
export { generateChecksumForReadable, generateChecksumForObject, generateChecksumForBufferOrString, } from './src/utils/checksumUtils';
|
|
26
|
+
export { FsReadableProvider } from './src/utils/streamUtils';
|
|
27
|
+
export type { PersistToFsOptions, ReadableProvider, FsReadableProviderOptions, } from './src/utils/streamUtils';
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "sendPut", { enumerable: true, get: function () { return httpClient_1.sendPut; } });
|
|
6
|
-
Object.defineProperty(exports, "sendPutBinary", { enumerable: true, get: function () { return httpClient_1.sendPutBinary; } });
|
|
7
|
-
Object.defineProperty(exports, "sendDelete", { enumerable: true, get: function () { return httpClient_1.sendDelete; } });
|
|
8
|
-
Object.defineProperty(exports, "sendPatch", { enumerable: true, get: function () { return httpClient_1.sendPatch; } });
|
|
9
|
-
Object.defineProperty(exports, "sendGet", { enumerable: true, get: function () { return httpClient_1.sendGet; } });
|
|
10
|
-
Object.defineProperty(exports, "sendPost", { enumerable: true, get: function () { return httpClient_1.sendPost; } });
|
|
11
|
-
Object.defineProperty(exports, "sendPostBinary", { enumerable: true, get: function () { return httpClient_1.sendPostBinary; } });
|
|
12
|
-
Object.defineProperty(exports, "httpClient", { enumerable: true, get: function () { return httpClient_1.httpClient; } });
|
|
13
|
-
Object.defineProperty(exports, "buildClient", { enumerable: true, get: function () { return httpClient_1.buildClient; } });
|
|
3
|
+
exports.generateChecksumForBufferOrString = exports.generateChecksumForObject = exports.generateChecksumForReadable = exports.waitAndRetry = exports.AuthFailedError = exports.EntityGoneError = exports.EntityNotFoundError = exports.AccessDeniedError = exports.RequestValidationError = exports.resolveGlobalErrorLogObject = exports.globalLogger = exports.executeSettleAllAndHandleGlobalErrors = exports.executeAndHandleGlobalErrors = exports.executeAsyncAndHandleGlobalErrors = exports.resolveMonorepoLoggerConfiguration = exports.resolveLoggerConfiguration = exports.HashEncoding = exports.HashAlgorithm = exports.generateHash = exports.hasMessage = exports.isPublicNonRecoverableError = exports.isObject = exports.isStandardizedError = exports.isInternalError = exports.isError = exports.deepClone = exports.convertDateFieldsToIsoString = exports.isEmptyObject = exports.copyWithoutEmpty = exports.copyWithoutUndefined = exports.pickWithoutUndefined = exports.pick = exports.groupByUnique = exports.groupByPath = exports.groupBy = exports.removeNullish = exports.removeFalsy = exports.callChunked = exports.chunk = exports.EncryptionUtility = exports.isFailure = exports.isSuccess = exports.failure = exports.success = exports.createRangeValidator = exports.ensureClosingSlashTransformer = exports.ConfigScope = exports.isEntityGoneError = exports.InternalError = exports.PublicNonRecoverableError = void 0;
|
|
4
|
+
exports.FsReadableProvider = void 0;
|
|
14
5
|
var PublicNonRecoverableError_1 = require("./src/errors/PublicNonRecoverableError");
|
|
15
6
|
Object.defineProperty(exports, "PublicNonRecoverableError", { enumerable: true, get: function () { return PublicNonRecoverableError_1.PublicNonRecoverableError; } });
|
|
16
7
|
var InternalError_1 = require("./src/errors/InternalError");
|
|
17
8
|
Object.defineProperty(exports, "InternalError", { enumerable: true, get: function () { return InternalError_1.InternalError; } });
|
|
18
|
-
var ResponseStatusError_1 = require("./src/errors/ResponseStatusError");
|
|
19
|
-
Object.defineProperty(exports, "ResponseStatusError", { enumerable: true, get: function () { return ResponseStatusError_1.ResponseStatusError; } });
|
|
20
9
|
var errorTypeGuards_1 = require("./src/errors/errorTypeGuards");
|
|
21
|
-
Object.defineProperty(exports, "
|
|
10
|
+
Object.defineProperty(exports, "isEntityGoneError", { enumerable: true, get: function () { return errorTypeGuards_1.isEntityGoneError; } });
|
|
22
11
|
var ConfigScope_1 = require("./src/config/ConfigScope");
|
|
23
12
|
Object.defineProperty(exports, "ConfigScope", { enumerable: true, get: function () { return ConfigScope_1.ConfigScope; } });
|
|
24
13
|
var configTransformers_1 = require("./src/config/configTransformers");
|
|
@@ -30,6 +19,8 @@ Object.defineProperty(exports, "success", { enumerable: true, get: function () {
|
|
|
30
19
|
Object.defineProperty(exports, "failure", { enumerable: true, get: function () { return either_1.failure; } });
|
|
31
20
|
Object.defineProperty(exports, "isSuccess", { enumerable: true, get: function () { return either_1.isSuccess; } });
|
|
32
21
|
Object.defineProperty(exports, "isFailure", { enumerable: true, get: function () { return either_1.isFailure; } });
|
|
22
|
+
var encryptionUtility_1 = require("./src/utils/encryptionUtility");
|
|
23
|
+
Object.defineProperty(exports, "EncryptionUtility", { enumerable: true, get: function () { return encryptionUtility_1.EncryptionUtility; } });
|
|
33
24
|
var arrayUtils_1 = require("./src/utils/arrayUtils");
|
|
34
25
|
Object.defineProperty(exports, "chunk", { enumerable: true, get: function () { return arrayUtils_1.chunk; } });
|
|
35
26
|
Object.defineProperty(exports, "callChunked", { enumerable: true, get: function () { return arrayUtils_1.callChunked; } });
|
|
@@ -37,19 +28,26 @@ Object.defineProperty(exports, "removeFalsy", { enumerable: true, get: function
|
|
|
37
28
|
Object.defineProperty(exports, "removeNullish", { enumerable: true, get: function () { return arrayUtils_1.removeNullish; } });
|
|
38
29
|
var objectUtils_1 = require("./src/utils/objectUtils");
|
|
39
30
|
Object.defineProperty(exports, "groupBy", { enumerable: true, get: function () { return objectUtils_1.groupBy; } });
|
|
31
|
+
Object.defineProperty(exports, "groupByPath", { enumerable: true, get: function () { return objectUtils_1.groupByPath; } });
|
|
40
32
|
Object.defineProperty(exports, "groupByUnique", { enumerable: true, get: function () { return objectUtils_1.groupByUnique; } });
|
|
41
33
|
Object.defineProperty(exports, "pick", { enumerable: true, get: function () { return objectUtils_1.pick; } });
|
|
42
34
|
Object.defineProperty(exports, "pickWithoutUndefined", { enumerable: true, get: function () { return objectUtils_1.pickWithoutUndefined; } });
|
|
43
35
|
Object.defineProperty(exports, "copyWithoutUndefined", { enumerable: true, get: function () { return objectUtils_1.copyWithoutUndefined; } });
|
|
36
|
+
Object.defineProperty(exports, "copyWithoutEmpty", { enumerable: true, get: function () { return objectUtils_1.copyWithoutEmpty; } });
|
|
44
37
|
Object.defineProperty(exports, "isEmptyObject", { enumerable: true, get: function () { return objectUtils_1.isEmptyObject; } });
|
|
45
38
|
Object.defineProperty(exports, "convertDateFieldsToIsoString", { enumerable: true, get: function () { return objectUtils_1.convertDateFieldsToIsoString; } });
|
|
46
39
|
Object.defineProperty(exports, "deepClone", { enumerable: true, get: function () { return objectUtils_1.deepClone; } });
|
|
47
40
|
var typeUtils_1 = require("./src/utils/typeUtils");
|
|
41
|
+
Object.defineProperty(exports, "isError", { enumerable: true, get: function () { return typeUtils_1.isError; } });
|
|
48
42
|
Object.defineProperty(exports, "isInternalError", { enumerable: true, get: function () { return typeUtils_1.isInternalError; } });
|
|
49
43
|
Object.defineProperty(exports, "isStandardizedError", { enumerable: true, get: function () { return typeUtils_1.isStandardizedError; } });
|
|
50
44
|
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return typeUtils_1.isObject; } });
|
|
51
45
|
Object.defineProperty(exports, "isPublicNonRecoverableError", { enumerable: true, get: function () { return typeUtils_1.isPublicNonRecoverableError; } });
|
|
52
46
|
Object.defineProperty(exports, "hasMessage", { enumerable: true, get: function () { return typeUtils_1.hasMessage; } });
|
|
47
|
+
var hashUtils_1 = require("./src/utils/hashUtils");
|
|
48
|
+
Object.defineProperty(exports, "generateHash", { enumerable: true, get: function () { return hashUtils_1.generateHash; } });
|
|
49
|
+
Object.defineProperty(exports, "HashAlgorithm", { enumerable: true, get: function () { return hashUtils_1.HashAlgorithm; } });
|
|
50
|
+
Object.defineProperty(exports, "HashEncoding", { enumerable: true, get: function () { return hashUtils_1.HashEncoding; } });
|
|
53
51
|
var loggerConfigResolver_1 = require("./src/logging/loggerConfigResolver");
|
|
54
52
|
Object.defineProperty(exports, "resolveLoggerConfiguration", { enumerable: true, get: function () { return loggerConfigResolver_1.resolveLoggerConfiguration; } });
|
|
55
53
|
Object.defineProperty(exports, "resolveMonorepoLoggerConfiguration", { enumerable: true, get: function () { return loggerConfigResolver_1.resolveMonorepoLoggerConfiguration; } });
|
|
@@ -63,7 +61,14 @@ var publicErrors_1 = require("./src/errors/publicErrors");
|
|
|
63
61
|
Object.defineProperty(exports, "RequestValidationError", { enumerable: true, get: function () { return publicErrors_1.RequestValidationError; } });
|
|
64
62
|
Object.defineProperty(exports, "AccessDeniedError", { enumerable: true, get: function () { return publicErrors_1.AccessDeniedError; } });
|
|
65
63
|
Object.defineProperty(exports, "EntityNotFoundError", { enumerable: true, get: function () { return publicErrors_1.EntityNotFoundError; } });
|
|
64
|
+
Object.defineProperty(exports, "EntityGoneError", { enumerable: true, get: function () { return publicErrors_1.EntityGoneError; } });
|
|
66
65
|
Object.defineProperty(exports, "AuthFailedError", { enumerable: true, get: function () { return publicErrors_1.AuthFailedError; } });
|
|
67
66
|
var waitUtils_1 = require("./src/utils/waitUtils");
|
|
68
67
|
Object.defineProperty(exports, "waitAndRetry", { enumerable: true, get: function () { return waitUtils_1.waitAndRetry; } });
|
|
68
|
+
var checksumUtils_1 = require("./src/utils/checksumUtils");
|
|
69
|
+
Object.defineProperty(exports, "generateChecksumForReadable", { enumerable: true, get: function () { return checksumUtils_1.generateChecksumForReadable; } });
|
|
70
|
+
Object.defineProperty(exports, "generateChecksumForObject", { enumerable: true, get: function () { return checksumUtils_1.generateChecksumForObject; } });
|
|
71
|
+
Object.defineProperty(exports, "generateChecksumForBufferOrString", { enumerable: true, get: function () { return checksumUtils_1.generateChecksumForBufferOrString; } });
|
|
72
|
+
var streamUtils_1 = require("./src/utils/streamUtils");
|
|
73
|
+
Object.defineProperty(exports, "FsReadableProvider", { enumerable: true, get: function () { return streamUtils_1.FsReadableProvider; } });
|
|
69
74
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;AAAA,oFAG+C;AAF7C,sIAAA,yBAAyB,OAAA;AAI3B,4DAImC;AAHjC,8GAAA,aAAa,OAAA;AAIf,gEAAgE;AAAvD,oHAAA,iBAAiB,OAAA;AAE1B,wDAAsD;AAA7C,0GAAA,WAAW,OAAA;AACpB,sEAA+E;AAAtE,mIAAA,6BAA6B,OAAA;AACtC,kEAAoE;AAA3D,wHAAA,oBAAoB,OAAA;AAQ7B,8CAO4B;AAJ1B,iGAAA,OAAO,OAAA;AACP,iGAAA,OAAO,OAAA;AACP,mGAAA,SAAS,OAAA;AACT,mGAAA,SAAS,OAAA;AAGX,mEAAiE;AAAxD,sHAAA,iBAAiB,OAAA;AAE1B,qDAAuF;AAA9E,mGAAA,KAAK,OAAA;AAAE,yGAAA,WAAW,OAAA;AAAE,yGAAA,WAAW,OAAA;AAAE,2GAAA,aAAa,OAAA;AACvD,uDAWgC;AAV9B,sGAAA,OAAO,OAAA;AACP,0GAAA,WAAW,OAAA;AACX,4GAAA,aAAa,OAAA;AACb,mGAAA,IAAI,OAAA;AACJ,mHAAA,oBAAoB,OAAA;AACpB,mHAAA,oBAAoB,OAAA;AACpB,+GAAA,gBAAgB,OAAA;AAChB,4GAAA,aAAa,OAAA;AACb,2HAAA,4BAA4B,OAAA;AAC5B,wGAAA,SAAS,OAAA;AAGX,mDAO8B;AAN5B,oGAAA,OAAO,OAAA;AACP,4GAAA,eAAe,OAAA;AACf,gHAAA,mBAAmB,OAAA;AACnB,qGAAA,QAAQ,OAAA;AACR,wHAAA,2BAA2B,OAAA;AAC3B,uGAAA,UAAU,OAAA;AAIZ,mDAAiF;AAAxE,yGAAA,YAAY,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,yGAAA,YAAY,OAAA;AAElD,2EAG2C;AAFzC,kIAAA,0BAA0B,OAAA;AAC1B,0IAAA,kCAAkC,OAAA;AAUpC,sEAMwC;AALtC,uIAAA,iCAAiC,OAAA;AACjC,kIAAA,4BAA4B,OAAA;AAC5B,2IAAA,qCAAqC,OAAA;AACrC,kHAAA,YAAY,OAAA;AACZ,iIAAA,2BAA2B,OAAA;AAK7B,0DASkC;AALhC,sHAAA,sBAAsB,OAAA;AACtB,iHAAA,iBAAiB,OAAA;AACjB,mHAAA,mBAAmB,OAAA;AACnB,+GAAA,eAAe,OAAA;AACf,+GAAA,eAAe,OAAA;AAGjB,mDAAoD;AAA3C,yGAAA,YAAY,OAAA;AAIrB,2DAIkC;AAHhC,4HAAA,2BAA2B,OAAA;AAC3B,0HAAA,yBAAyB,OAAA;AACzB,kIAAA,iCAAiC,OAAA;AAEnC,uDAA4D;AAAnD,iHAAA,kBAAkB,OAAA"}
|
|
@@ -5,7 +5,9 @@ class InternalError extends Error {
|
|
|
5
5
|
details;
|
|
6
6
|
errorCode;
|
|
7
7
|
constructor(params) {
|
|
8
|
-
super(params.message
|
|
8
|
+
super(params.message, {
|
|
9
|
+
cause: params.cause,
|
|
10
|
+
});
|
|
9
11
|
this.name = 'InternalError';
|
|
10
12
|
this.details = params.details;
|
|
11
13
|
this.errorCode = params.errorCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalError.js","sourceRoot":"","sources":["../../../src/errors/InternalError.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"InternalError.js","sourceRoot":"","sources":["../../../src/errors/InternalError.ts"],"names":[],"mappings":";;;AASA,MAAa,aAAgC,SAAQ,KAAK;IACxC,OAAO,CAAI;IACX,SAAS,CAAQ;IAEjC,YAAY,MAA8B;QACxC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;YACpB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;IACnC,CAAC;CACF;AAZD,sCAYC"}
|
|
@@ -9,7 +9,9 @@ class PublicNonRecoverableError extends Error {
|
|
|
9
9
|
errorCode;
|
|
10
10
|
httpStatusCode;
|
|
11
11
|
constructor(params) {
|
|
12
|
-
super(params.message
|
|
12
|
+
super(params.message, {
|
|
13
|
+
cause: params.cause,
|
|
14
|
+
});
|
|
13
15
|
this.name = 'PublicNonRecoverableError';
|
|
14
16
|
this.details = params.details;
|
|
15
17
|
this.errorCode = params.errorCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicNonRecoverableError.js","sourceRoot":"","sources":["../../../src/errors/PublicNonRecoverableError.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PublicNonRecoverableError.js","sourceRoot":"","sources":["../../../src/errors/PublicNonRecoverableError.ts"],"names":[],"mappings":";;;AAUA;;GAEG;AACH,MAAa,yBAA0B,SAAQ,KAAK;IAClC,OAAO,CAAe;IACtB,SAAS,CAAQ;IACjB,cAAc,CAAQ;IAEtC,YAAY,MAAuC;QACjD,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE;YACpB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;QACvC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,GAAG,CAAA;IACpD,CAAC;CACF;AAdD,8DAcC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
1
|
+
import type { EntityGoneError } from './publicErrors';
|
|
2
|
+
export declare function isEntityGoneError(entity: unknown): entity is EntityGoneError;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
exports.isEntityGoneError = void 0;
|
|
4
|
+
const typeUtils_1 = require("../utils/typeUtils");
|
|
5
|
+
function isEntityGoneError(entity) {
|
|
6
|
+
return (0, typeUtils_1.isPublicNonRecoverableError)(entity) && entity.httpStatusCode === 410;
|
|
6
7
|
}
|
|
7
|
-
exports.
|
|
8
|
+
exports.isEntityGoneError = isEntityGoneError;
|
|
8
9
|
//# sourceMappingURL=errorTypeGuards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorTypeGuards.js","sourceRoot":"","sources":["../../../src/errors/errorTypeGuards.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"errorTypeGuards.js","sourceRoot":"","sources":["../../../src/errors/errorTypeGuards.ts"],"names":[],"mappings":";;;AAAA,kDAAgE;AAIhE,SAAgB,iBAAiB,CAAC,MAAe;IAC/C,OAAO,IAAA,uCAA2B,EAAC,MAAM,CAAC,IAAI,MAAM,CAAC,cAAc,KAAK,GAAG,CAAA;AAC7E,CAAC;AAFD,8CAEC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type: string;
|
|
1
|
+
import type { SerializedError } from 'pino';
|
|
2
|
+
import type { CommonLogger } from '../logging/commonLogger';
|
|
3
|
+
type LogObject = {
|
|
5
4
|
message: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
cause?: undefined;
|
|
5
|
+
'x-request-id'?: string;
|
|
6
|
+
error?: SerializedError;
|
|
9
7
|
};
|
|
8
|
+
export declare const globalLogger: CommonLogger;
|
|
9
|
+
export declare function resolveGlobalErrorLogObject(err: unknown, correlationId?: string): LogObject;
|
|
10
10
|
export declare function executeAndHandleGlobalErrors<T>(operation: () => T): T;
|
|
11
11
|
export declare function executeAsyncAndHandleGlobalErrors<T>(operation: () => Promise<T>, stopOnError?: boolean): Promise<T | undefined>;
|
|
12
12
|
export declare function executeSettleAllAndHandleGlobalErrors(promises: Promise<unknown>[], stopOnError?: boolean): Promise<PromiseSettledResult<unknown>[]>;
|
|
13
|
+
export {};
|
|
@@ -12,27 +12,26 @@ exports.globalLogger = (0, pino_1.pino)({
|
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
|
-
function resolveGlobalErrorLogObject(err,
|
|
15
|
+
function resolveGlobalErrorLogObject(err, correlationId) {
|
|
16
16
|
if (node_util_1.types.isNativeError(err)) {
|
|
17
17
|
return {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
message: err.message,
|
|
19
|
+
error: pino_1.stdSerializers.err(err),
|
|
20
|
+
'x-request-id': correlationId,
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
if ((0, typeUtils_1.hasMessage)(err)) {
|
|
23
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
message: err.message,
|
|
26
|
+
'x-request-id': correlationId,
|
|
27
|
+
};
|
|
24
28
|
}
|
|
25
|
-
return
|
|
29
|
+
return {
|
|
30
|
+
message: 'Unknown error',
|
|
31
|
+
'x-request-id': correlationId,
|
|
32
|
+
};
|
|
26
33
|
}
|
|
27
34
|
exports.resolveGlobalErrorLogObject = resolveGlobalErrorLogObject;
|
|
28
|
-
function logGlobalErrorLogObject(logObject) {
|
|
29
|
-
if (typeof logObject === 'string') {
|
|
30
|
-
exports.globalLogger.error(`Global error: ${logObject}`);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
exports.globalLogger.error(logObject, logObject.message);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
35
|
function executeAndHandleGlobalErrors(operation) {
|
|
37
36
|
try {
|
|
38
37
|
const result = operation();
|
|
@@ -40,7 +39,7 @@ function executeAndHandleGlobalErrors(operation) {
|
|
|
40
39
|
}
|
|
41
40
|
catch (err) {
|
|
42
41
|
const logObject = resolveGlobalErrorLogObject(err);
|
|
43
|
-
|
|
42
|
+
exports.globalLogger.error(logObject, logObject.message);
|
|
44
43
|
process.exit(1);
|
|
45
44
|
}
|
|
46
45
|
}
|
|
@@ -52,7 +51,7 @@ async function executeAsyncAndHandleGlobalErrors(operation, stopOnError = true)
|
|
|
52
51
|
}
|
|
53
52
|
catch (err) {
|
|
54
53
|
const logObject = resolveGlobalErrorLogObject(err);
|
|
55
|
-
|
|
54
|
+
exports.globalLogger.error(logObject, logObject.message);
|
|
56
55
|
if (stopOnError) {
|
|
57
56
|
process.exit(1);
|
|
58
57
|
}
|
|
@@ -65,7 +64,7 @@ async function executeSettleAllAndHandleGlobalErrors(promises, stopOnError = tru
|
|
|
65
64
|
for (const entry of result) {
|
|
66
65
|
if (entry.status === 'rejected') {
|
|
67
66
|
const logObject = resolveGlobalErrorLogObject(entry.reason);
|
|
68
|
-
|
|
67
|
+
exports.globalLogger.error(logObject, logObject.message);
|
|
69
68
|
errorsHappened = true;
|
|
70
69
|
}
|
|
71
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalErrorHandler.js","sourceRoot":"","sources":["../../../src/errors/globalErrorHandler.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,+BAAmD;
|
|
1
|
+
{"version":3,"file":"globalErrorHandler.js","sourceRoot":"","sources":["../../../src/errors/globalErrorHandler.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,+BAAmD;AAGnD,kDAA+C;AAQlC,QAAA,YAAY,GAAiB,IAAA,WAAI,EAAC;IAC7C,UAAU,EAAE;QACV,KAAK,EAAE,CAAC,KAAK,EAAE,YAAY,EAAqB,EAAE;YAChD,MAAM,KAAK,GAAG,aAAM,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,SAAS,CAAA;YACtD,OAAO,EAAE,KAAK,EAAE,CAAA;QAClB,CAAC;KACF;CACF,CAAC,CAAA;AAEF,SAAgB,2BAA2B,CAAC,GAAY,EAAE,aAAsB;IAC9E,IAAI,iBAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,KAAK,EAAE,qBAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAC9B,cAAc,EAAE,aAAa;SAC9B,CAAA;IACH,CAAC;IAED,IAAI,IAAA,sBAAU,EAAC,GAAG,CAAC,EAAE,CAAC;QACpB,OAAO;YACL,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,cAAc,EAAE,aAAa;SAC9B,CAAA;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,eAAe;QACxB,cAAc,EAAE,aAAa;KAC9B,CAAA;AACH,CAAC;AApBD,kEAoBC;AAED,SAAgB,4BAA4B,CAAI,SAAkB;IAChE,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAA;QAClD,oBAAY,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC;AATD,oEASC;AAEM,KAAK,UAAU,iCAAiC,CACrD,SAA2B,EAC3B,WAAW,GAAG,IAAI;IAElB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAA;QAChC,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAA;QAClD,oBAAY,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;QAChD,IAAI,WAAW,EAAE,CAAC;YAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC;AACH,CAAC;AAdD,8EAcC;AAEM,KAAK,UAAU,qCAAqC,CACzD,QAA4B,EAC5B,WAAW,GAAG,IAAI;IAElB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IAEjD,IAAI,cAAc,CAAA;IAClB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YAChC,MAAM,SAAS,GAAG,2BAA2B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;YAC3D,oBAAY,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,CAAA;YAChD,cAAc,GAAG,IAAI,CAAA;QACvB,CAAC;IACH,CAAC;IAED,IAAI,WAAW,IAAI,cAAc,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AApBD,sFAoBC"}
|
|
@@ -3,11 +3,9 @@ import { PublicNonRecoverableError } from './PublicNonRecoverableError';
|
|
|
3
3
|
export type CommonErrorParams = {
|
|
4
4
|
message: string;
|
|
5
5
|
details?: FreeformRecord;
|
|
6
|
+
cause?: Error;
|
|
6
7
|
};
|
|
7
|
-
export type OptionalMessageErrorParams =
|
|
8
|
-
message?: string;
|
|
9
|
-
details?: FreeformRecord;
|
|
10
|
-
};
|
|
8
|
+
export type OptionalMessageErrorParams = Partial<CommonErrorParams>;
|
|
11
9
|
export type ValidationError = {
|
|
12
10
|
message: string;
|
|
13
11
|
path: string[];
|
|
@@ -21,6 +19,9 @@ export declare class AccessDeniedError extends PublicNonRecoverableError {
|
|
|
21
19
|
export declare class EntityNotFoundError extends PublicNonRecoverableError {
|
|
22
20
|
constructor(params: CommonErrorParams);
|
|
23
21
|
}
|
|
22
|
+
export declare class EntityGoneError extends PublicNonRecoverableError {
|
|
23
|
+
constructor(params: CommonErrorParams);
|
|
24
|
+
}
|
|
24
25
|
export declare class AuthFailedError extends PublicNonRecoverableError {
|
|
25
26
|
constructor(params?: OptionalMessageErrorParams);
|
|
26
27
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AuthFailedError = exports.EntityNotFoundError = exports.AccessDeniedError = exports.RequestValidationError = void 0;
|
|
3
|
+
exports.AuthFailedError = exports.EntityGoneError = exports.EntityNotFoundError = exports.AccessDeniedError = exports.RequestValidationError = void 0;
|
|
4
4
|
const node_http2_1 = require("node:http2");
|
|
5
5
|
const PublicNonRecoverableError_1 = require("./PublicNonRecoverableError");
|
|
6
6
|
class RequestValidationError extends PublicNonRecoverableError_1.PublicNonRecoverableError {
|
|
@@ -23,6 +23,7 @@ class AccessDeniedError extends PublicNonRecoverableError_1.PublicNonRecoverable
|
|
|
23
23
|
errorCode: 'ACCESS_DENIED',
|
|
24
24
|
httpStatusCode: node_http2_1.constants.HTTP_STATUS_FORBIDDEN,
|
|
25
25
|
details: params.details,
|
|
26
|
+
cause: params.cause,
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -34,10 +35,22 @@ class EntityNotFoundError extends PublicNonRecoverableError_1.PublicNonRecoverab
|
|
|
34
35
|
errorCode: 'ENTITY_NOT_FOUND',
|
|
35
36
|
httpStatusCode: node_http2_1.constants.HTTP_STATUS_NOT_FOUND,
|
|
36
37
|
details: params.details,
|
|
38
|
+
cause: params.cause,
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
exports.EntityNotFoundError = EntityNotFoundError;
|
|
43
|
+
class EntityGoneError extends PublicNonRecoverableError_1.PublicNonRecoverableError {
|
|
44
|
+
constructor(params) {
|
|
45
|
+
super({
|
|
46
|
+
message: params.message,
|
|
47
|
+
errorCode: 'ENTITY_GONE',
|
|
48
|
+
httpStatusCode: 410,
|
|
49
|
+
details: params.details,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.EntityGoneError = EntityGoneError;
|
|
41
54
|
class AuthFailedError extends PublicNonRecoverableError_1.PublicNonRecoverableError {
|
|
42
55
|
constructor(params = {}) {
|
|
43
56
|
super({
|
|
@@ -45,6 +58,7 @@ class AuthFailedError extends PublicNonRecoverableError_1.PublicNonRecoverableEr
|
|
|
45
58
|
errorCode: 'AUTH_FAILED',
|
|
46
59
|
httpStatusCode: node_http2_1.constants.HTTP_STATUS_UNAUTHORIZED,
|
|
47
60
|
details: params.details,
|
|
61
|
+
cause: params.cause,
|
|
48
62
|
});
|
|
49
63
|
}
|
|
50
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicErrors.js","sourceRoot":"","sources":["../../../src/errors/publicErrors.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AAIvD,2EAAuE;
|
|
1
|
+
{"version":3,"file":"publicErrors.js","sourceRoot":"","sources":["../../../src/errors/publicErrors.ts"],"names":[],"mappings":";;;AAAA,2CAAuD;AAIvD,2EAAuE;AAevE,MAAa,sBAAuB,SAAQ,qDAAyB;IACnE,YAAY,MAAyB;QACnC,KAAK,CAAC;YACJ,OAAO,EAAE,gBAAgB;YACzB,SAAS,EAAE,kBAAkB;YAC7B,cAAc,EAAE,sBAAa,CAAC,uBAAuB;YACrD,OAAO,EAAE;gBACP,KAAK,EAAE,MAAM;aACd;SACF,CAAC,CAAA;IACJ,CAAC;CACF;AAXD,wDAWC;AAED,MAAa,iBAAkB,SAAQ,qDAAyB;IAC9D,YAAY,MAAyB;QACnC,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,eAAe;YAC1B,cAAc,EAAE,sBAAa,CAAC,qBAAqB;YACnD,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;IACJ,CAAC;CACF;AAVD,8CAUC;AAED,MAAa,mBAAoB,SAAQ,qDAAyB;IAChE,YAAY,MAAyB;QACnC,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,kBAAkB;YAC7B,cAAc,EAAE,sBAAa,CAAC,qBAAqB;YACnD,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;IACJ,CAAC;CACF;AAVD,kDAUC;AAED,MAAa,eAAgB,SAAQ,qDAAyB;IAC5D,YAAY,MAAyB;QACnC,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,aAAa;YACxB,cAAc,EAAE,GAAG;YACnB,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAA;IACJ,CAAC;CACF;AATD,0CASC;AAED,MAAa,eAAgB,SAAQ,qDAAyB;IAC5D,YAAY,SAAqC,EAAE;QACjD,KAAK,CAAC;YACJ,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,uBAAuB;YAClD,SAAS,EAAE,aAAa;YACxB,cAAc,EAAE,sBAAa,CAAC,wBAAwB;YACtD,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAA;IACJ,CAAC;CACF;AAVD,0CAUC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BaseLogger, Bindings, ChildLoggerOptions } from 'pino';
|
|
2
|
+
export type CommonLogger = BaseLogger & {
|
|
3
|
+
/**
|
|
4
|
+
* Creates a child logger, setting all key-value pairs in `bindings` as properties in the log lines. All serializers will be applied to the given pair.
|
|
5
|
+
* Child loggers use the same output stream as the parent and inherit the current log level of the parent at the time they are spawned.
|
|
6
|
+
* If a `level` property is present in the object passed to `child` it will override the child logger level.
|
|
7
|
+
*
|
|
8
|
+
* @param bindings: an object of key-value pairs to include in log lines as properties.
|
|
9
|
+
* @param options: an options object that will override child logger inherited options.
|
|
10
|
+
* @returns a child logger instance.
|
|
11
|
+
*/
|
|
12
|
+
child(bindings: Bindings, options?: ChildLoggerOptions): CommonLogger;
|
|
13
|
+
/**
|
|
14
|
+
* A utility method for determining if a given log level will write to the destination.
|
|
15
|
+
*/
|
|
16
|
+
isLevelEnabled(level: string): boolean;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commonLogger.js","sourceRoot":"","sources":["../../../src/logging/commonLogger.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LoggerOptions } from 'pino';
|
|
1
|
+
import type { Logger, LoggerOptions } from 'pino';
|
|
2
2
|
export type AppLoggerConfig = {
|
|
3
3
|
logLevel: 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
|
|
4
4
|
nodeEnv: 'production' | 'development' | 'test';
|
|
@@ -8,5 +8,5 @@ export type MonorepoAppLoggerConfig = AppLoggerConfig & {
|
|
|
8
8
|
targetFile?: string;
|
|
9
9
|
append?: boolean;
|
|
10
10
|
};
|
|
11
|
-
export declare function resolveMonorepoLoggerConfiguration(appConfig: MonorepoAppLoggerConfig): LoggerOptions;
|
|
12
|
-
export declare function resolveLoggerConfiguration(appConfig: AppLoggerConfig): LoggerOptions;
|
|
11
|
+
export declare function resolveMonorepoLoggerConfiguration(appConfig: MonorepoAppLoggerConfig): LoggerOptions | Logger | boolean;
|
|
12
|
+
export declare function resolveLoggerConfiguration(appConfig: AppLoggerConfig): LoggerOptions | Logger | boolean;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveLoggerConfiguration = exports.resolveMonorepoLoggerConfiguration = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pino_1 = require("pino");
|
|
6
|
+
const pino_pretty_1 = tslib_1.__importDefault(require("pino-pretty"));
|
|
4
7
|
// Note that transports do not work in vitest, likely because pino attempts to run them in a separate worker
|
|
5
8
|
/* c8 ignore next 24 */
|
|
6
9
|
function resolveMonorepoLoggerConfiguration(appConfig) {
|
|
@@ -26,26 +29,24 @@ function resolveMonorepoLoggerConfiguration(appConfig) {
|
|
|
26
29
|
}
|
|
27
30
|
exports.resolveMonorepoLoggerConfiguration = resolveMonorepoLoggerConfiguration;
|
|
28
31
|
function resolveLoggerConfiguration(appConfig) {
|
|
29
|
-
|
|
32
|
+
if (appConfig.nodeEnv !== 'production') {
|
|
33
|
+
return (0, pino_1.pino)((0, pino_pretty_1.default)({
|
|
34
|
+
sync: true,
|
|
35
|
+
minimumLevel: appConfig.logLevel,
|
|
36
|
+
colorize: true,
|
|
37
|
+
translateTime: 'SYS:standard',
|
|
38
|
+
ignore: 'hostname,pid',
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
30
42
|
level: appConfig.logLevel,
|
|
31
43
|
formatters: {
|
|
32
|
-
level: (
|
|
33
|
-
|
|
44
|
+
level: (_label, numericLevel) => {
|
|
45
|
+
const level = pino_1.levels.labels[numericLevel] || 'unknown';
|
|
46
|
+
return { level };
|
|
34
47
|
},
|
|
35
48
|
},
|
|
36
|
-
base: appConfig.base,
|
|
37
49
|
};
|
|
38
|
-
if (appConfig.nodeEnv !== 'production') {
|
|
39
|
-
config.transport = {
|
|
40
|
-
target: 'pino-pretty',
|
|
41
|
-
options: {
|
|
42
|
-
colorize: true,
|
|
43
|
-
translateTime: 'SYS:standard',
|
|
44
|
-
ignore: 'hostname,pid',
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
return config;
|
|
49
50
|
}
|
|
50
51
|
exports.resolveLoggerConfiguration = resolveLoggerConfiguration;
|
|
51
52
|
//# sourceMappingURL=loggerConfigResolver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggerConfigResolver.js","sourceRoot":"","sources":["../../../src/logging/loggerConfigResolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loggerConfigResolver.js","sourceRoot":"","sources":["../../../src/logging/loggerConfigResolver.ts"],"names":[],"mappings":";;;;AACA,+BAAmC;AACnC,sEAAgC;AAahC,4GAA4G;AAC5G,uBAAuB;AACvB,SAAgB,kCAAkC,CAChD,SAAkC;IAElC,IAAI,SAAS,CAAC,OAAO,KAAK,aAAa,EAAE,CAAC;QACxC,OAAO,0BAA0B,CAAC,SAAS,CAAC,CAAA;IAC9C,CAAC;IAED,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,QAAQ;QACzB,UAAU,EAAE;YACV,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;gBACf,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;YACzB,CAAC;SACF;QACD,SAAS,EAAE;YACT,MAAM,EAAE,WAAW;YACnB,OAAO,EAAE;gBACP,WAAW,EAAE,SAAS,CAAC,UAAU,IAAI,eAAe;gBACpD,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,SAAS,CAAC,MAAM,IAAI,KAAK;aAClC;SACF;KACF,CAAA;AACH,CAAC;AAvBD,gFAuBC;AAED,SAAgB,0BAA0B,CACxC,SAA0B;IAE1B,IAAI,SAAS,CAAC,OAAO,KAAK,YAAY,EAAE,CAAC;QACvC,OAAO,IAAA,WAAI,EACT,IAAA,qBAAM,EAAC;YACL,IAAI,EAAE,IAAI;YACV,YAAY,EAAE,SAAS,CAAC,QAAiB;YACzC,QAAQ,EAAE,IAAI;YACd,aAAa,EAAE,cAAc;YAC7B,MAAM,EAAE,cAAc;SACvB,CAAC,CACH,CAAA;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,QAAQ;QACzB,UAAU,EAAE;YACV,KAAK,EAAE,CAAC,MAAM,EAAE,YAAY,EAAqB,EAAE;gBACjD,MAAM,KAAK,GAAG,aAAM,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,SAAS,CAAA;gBACtD,OAAO,EAAE,KAAK,EAAE,CAAA;YAClB,CAAC;SACF;KACsB,CAAA;AAC3B,CAAC;AAxBD,gEAwBC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type TransactionObservabilityManager = {
|
|
2
|
+
/**
|
|
3
|
+
* Creates and starts a background transaction to record work done
|
|
4
|
+
*
|
|
5
|
+
* @param transactionName - used for grouping similar transactions together
|
|
6
|
+
* @param uniqueTransactionKey - used for identifying specific ongoing transaction. Must be reasonably unique to reduce possibility of collisions
|
|
7
|
+
*/
|
|
8
|
+
start: (transactionName: string, uniqueTransactionKey: string) => unknown;
|
|
9
|
+
/**
|
|
10
|
+
* Creates and starts a background transaction to record work done, and relates it to a specified group
|
|
11
|
+
*
|
|
12
|
+
* @param transactionName - used for grouping similar transactions together
|
|
13
|
+
* @param uniqueTransactionKey - used for identifying specific ongoing transaction. Must be reasonably unique to reduce possibility of collisions *
|
|
14
|
+
* @param transactionGroup - group is used for grouping related transactions with different names
|
|
15
|
+
*/
|
|
16
|
+
startWithGroup: (transactionName: string, uniqueTransactionKey: string, transactionGroup: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Ends the transaction
|
|
19
|
+
* @param uniqueTransactionKey - used for identifying specific ongoing transaction. Must be reasonably unique to reduce possibility of collisions
|
|
20
|
+
*/
|
|
21
|
+
stop: (uniqueTransactionKey: string) => unknown;
|
|
22
|
+
};
|