@lokalise/node-core 12.5.1 → 13.0.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/dist/index.cjs +985 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +404 -0
- package/dist/index.d.ts +404 -29
- package/dist/index.js +893 -78
- package/dist/index.js.map +1 -1
- package/package.json +13 -7
- package/dist/src/common/commonTypes.d.ts +0 -1
- package/dist/src/common/commonTypes.js +0 -3
- package/dist/src/common/commonTypes.js.map +0 -1
- package/dist/src/common/may-omit.d.ts +0 -1
- package/dist/src/common/may-omit.js +0 -3
- package/dist/src/common/may-omit.js.map +0 -1
- package/dist/src/config/ConfigScope.d.ts +0 -34
- package/dist/src/config/ConfigScope.js +0 -173
- package/dist/src/config/ConfigScope.js.map +0 -1
- package/dist/src/config/configTransformers.d.ts +0 -2
- package/dist/src/config/configTransformers.js +0 -15
- package/dist/src/config/configTransformers.js.map +0 -1
- package/dist/src/config/configTypes.d.ts +0 -30
- package/dist/src/config/configTypes.js +0 -3
- package/dist/src/config/configTypes.js.map +0 -1
- package/dist/src/config/configValidators.d.ts +0 -2
- package/dist/src/config/configValidators.js +0 -10
- package/dist/src/config/configValidators.js.map +0 -1
- package/dist/src/errors/InternalError.d.ts +0 -16
- package/dist/src/errors/InternalError.js +0 -29
- package/dist/src/errors/InternalError.js.map +0 -1
- package/dist/src/errors/PublicNonRecoverableError.d.ts +0 -21
- package/dist/src/errors/PublicNonRecoverableError.js +0 -34
- package/dist/src/errors/PublicNonRecoverableError.js.map +0 -1
- package/dist/src/errors/either.d.ts +0 -28
- package/dist/src/errors/either.js +0 -16
- package/dist/src/errors/either.js.map +0 -1
- package/dist/src/errors/errorReporterTypes.d.ts +0 -14
- package/dist/src/errors/errorReporterTypes.js +0 -3
- package/dist/src/errors/errorReporterTypes.js.map +0 -1
- package/dist/src/errors/errorTypeGuards.d.ts +0 -2
- package/dist/src/errors/errorTypeGuards.js +0 -8
- package/dist/src/errors/errorTypeGuards.js.map +0 -1
- package/dist/src/errors/globalErrorHandler.d.ts +0 -13
- package/dist/src/errors/globalErrorHandler.js +0 -77
- package/dist/src/errors/globalErrorHandler.js.map +0 -1
- package/dist/src/errors/publicErrors.d.ts +0 -27
- package/dist/src/errors/publicErrors.js +0 -66
- package/dist/src/errors/publicErrors.js.map +0 -1
- package/dist/src/errors/types.d.ts +0 -1
- package/dist/src/errors/types.js +0 -3
- package/dist/src/errors/types.js.map +0 -1
- package/dist/src/logging/commonLogger.d.ts +0 -17
- package/dist/src/logging/commonLogger.js +0 -3
- package/dist/src/logging/commonLogger.js.map +0 -1
- package/dist/src/logging/loggerConfigResolver.d.ts +0 -15
- package/dist/src/logging/loggerConfigResolver.js +0 -70
- package/dist/src/logging/loggerConfigResolver.js.map +0 -1
- package/dist/src/observability/MultiTransactionObservabilityManager.d.ts +0 -12
- package/dist/src/observability/MultiTransactionObservabilityManager.js +0 -30
- package/dist/src/observability/MultiTransactionObservabilityManager.js.map +0 -1
- package/dist/src/observability/observabilityTypes.d.ts +0 -23
- package/dist/src/observability/observabilityTypes.js +0 -3
- package/dist/src/observability/observabilityTypes.js.map +0 -1
- package/dist/src/utils/arrayUtils.d.ts +0 -14
- package/dist/src/utils/arrayUtils.js +0 -47
- package/dist/src/utils/arrayUtils.js.map +0 -1
- package/dist/src/utils/checksumUtils.d.ts +0 -5
- package/dist/src/utils/checksumUtils.js +0 -37
- package/dist/src/utils/checksumUtils.js.map +0 -1
- package/dist/src/utils/encryptionUtility.d.ts +0 -20
- package/dist/src/utils/encryptionUtility.js +0 -58
- package/dist/src/utils/encryptionUtility.js.map +0 -1
- package/dist/src/utils/hashUtils.d.ts +0 -9
- package/dist/src/utils/hashUtils.js +0 -19
- package/dist/src/utils/hashUtils.js.map +0 -1
- package/dist/src/utils/objectUtils.d.ts +0 -55
- package/dist/src/utils/objectUtils.js +0 -195
- package/dist/src/utils/objectUtils.js.map +0 -1
- package/dist/src/utils/streamUtils.d.ts +0 -37
- package/dist/src/utils/streamUtils.js +0 -85
- package/dist/src/utils/streamUtils.js.map +0 -1
- package/dist/src/utils/typeUtils.d.ts +0 -10
- package/dist/src/utils/typeUtils.js +0 -19
- package/dist/src/utils/typeUtils.js.map +0 -1
- package/dist/src/utils/waitUtils.d.ts +0 -1
- package/dist/src/utils/waitUtils.js +0 -34
- package/dist/src/utils/waitUtils.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,79 +1,894 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
// src/utils/typeUtils.ts
|
|
2
|
+
function hasMessage(maybe) {
|
|
3
|
+
return isObject(maybe) && typeof maybe.message === "string";
|
|
4
|
+
}
|
|
5
|
+
function isObject(maybeObject) {
|
|
6
|
+
return typeof maybeObject === "object" && maybeObject !== null;
|
|
7
|
+
}
|
|
8
|
+
function isStandardizedError(error) {
|
|
9
|
+
return isObject(error) && typeof error.code === "string" && typeof error.message === "string";
|
|
10
|
+
}
|
|
11
|
+
function isError(maybeError) {
|
|
12
|
+
return maybeError instanceof Error || Object.prototype.toString.call(maybeError) === "[object Error]";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/errors/PublicNonRecoverableError.ts
|
|
16
|
+
var PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY = "PUBLIC_NON_RECOVERABLE_ERROR_KEY";
|
|
17
|
+
var publicNonRecoverableErrorSymbol = Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY);
|
|
18
|
+
var PublicNonRecoverableError = class extends Error {
|
|
19
|
+
[publicNonRecoverableErrorSymbol] = true;
|
|
20
|
+
details;
|
|
21
|
+
errorCode;
|
|
22
|
+
httpStatusCode;
|
|
23
|
+
constructor(params) {
|
|
24
|
+
super(params.message, {
|
|
25
|
+
cause: params.cause
|
|
26
|
+
});
|
|
27
|
+
this.name = this.constructor.name;
|
|
28
|
+
this.details = params.details;
|
|
29
|
+
this.errorCode = params.errorCode;
|
|
30
|
+
this.httpStatusCode = params.httpStatusCode ?? 500;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
function isPublicNonRecoverableError(error) {
|
|
34
|
+
return isError(error) && // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface
|
|
35
|
+
(error[Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)] === true || error.name === "PublicNonRecoverableError");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// src/errors/InternalError.ts
|
|
39
|
+
var INTERNAL_ERROR_SYMBOL_KEY = "INTERNAL_ERROR_KEY";
|
|
40
|
+
var internalErrorSymbol = Symbol.for(INTERNAL_ERROR_SYMBOL_KEY);
|
|
41
|
+
var InternalError = class extends Error {
|
|
42
|
+
[internalErrorSymbol] = true;
|
|
43
|
+
details;
|
|
44
|
+
errorCode;
|
|
45
|
+
constructor(params) {
|
|
46
|
+
super(params.message, {
|
|
47
|
+
cause: params.cause
|
|
48
|
+
});
|
|
49
|
+
this.name = this.constructor.name;
|
|
50
|
+
this.details = params.details;
|
|
51
|
+
this.errorCode = params.errorCode;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function isInternalError(error) {
|
|
55
|
+
return isError(error) && // biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface
|
|
56
|
+
(error[Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)] === true || error.name === "InternalError");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/errors/errorTypeGuards.ts
|
|
60
|
+
function isEntityGoneError(entity) {
|
|
61
|
+
return isPublicNonRecoverableError(entity) && entity.httpStatusCode === 410;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/config/ConfigScope.ts
|
|
65
|
+
var ConfigScope = class {
|
|
66
|
+
env;
|
|
67
|
+
constructor(envOverride) {
|
|
68
|
+
this.env = envOverride ?? { ...process.env };
|
|
69
|
+
}
|
|
70
|
+
updateEnv() {
|
|
71
|
+
this.env = { ...process.env };
|
|
72
|
+
}
|
|
73
|
+
getMandatoryInteger(param) {
|
|
74
|
+
const rawValue = this.env[param];
|
|
75
|
+
if (!rawValue) {
|
|
76
|
+
throw new InternalError({
|
|
77
|
+
message: `Missing mandatory configuration parameter: ${param}`,
|
|
78
|
+
errorCode: "CONFIGURATION_ERROR"
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return validateNumber(
|
|
82
|
+
Number.parseInt(rawValue),
|
|
83
|
+
`Configuration parameter ${param}\` must be a number, but was ${rawValue}`
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
getMandatory(param) {
|
|
87
|
+
const result = this.env[param];
|
|
88
|
+
if (!result) {
|
|
89
|
+
throw new InternalError({
|
|
90
|
+
message: `Missing mandatory configuration parameter: ${param}`,
|
|
91
|
+
errorCode: "CONFIGURATION_ERROR"
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
getMandatoryOneOf(param, supportedValues) {
|
|
97
|
+
const result = this.getMandatory(param);
|
|
98
|
+
return validateOneOf(
|
|
99
|
+
result,
|
|
100
|
+
supportedValues,
|
|
101
|
+
`Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
getMandatoryValidatedInteger(param, validator) {
|
|
105
|
+
const value = this.getMandatoryInteger(param);
|
|
106
|
+
if (!validator(value)) {
|
|
107
|
+
throw new InternalError({
|
|
108
|
+
message: `Value ${value} is invalid for parameter ${param}`,
|
|
109
|
+
errorCode: "CONFIGURATION_ERROR"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
getOptionalNullable(param, defaultValue) {
|
|
115
|
+
return this.env[param] || defaultValue;
|
|
116
|
+
}
|
|
117
|
+
getOptional(param, defaultValue) {
|
|
118
|
+
return this.env[param] || defaultValue;
|
|
119
|
+
}
|
|
120
|
+
getOptionalInteger(param, defaultValue) {
|
|
121
|
+
const rawValue = this.env[param];
|
|
122
|
+
if (!rawValue) {
|
|
123
|
+
return defaultValue;
|
|
124
|
+
}
|
|
125
|
+
return validateNumber(
|
|
126
|
+
Number.parseInt(rawValue),
|
|
127
|
+
`Configuration parameter ${param}\` must be a number, but was ${rawValue}`
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
getOptionalNullableInteger(param, defaultValue) {
|
|
131
|
+
const rawValue = this.env[param];
|
|
132
|
+
if (!rawValue) {
|
|
133
|
+
return defaultValue;
|
|
134
|
+
}
|
|
135
|
+
return validateNumber(
|
|
136
|
+
Number.parseInt(rawValue),
|
|
137
|
+
`Configuration parameter ${param}\` must be a number, but was ${rawValue}`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
getOptionalOneOf(param, defaultValue, supportedValues) {
|
|
141
|
+
const result = this.getOptional(param, defaultValue);
|
|
142
|
+
return validateOneOf(
|
|
143
|
+
result,
|
|
144
|
+
supportedValues,
|
|
145
|
+
`Unsupported ${param}: ${result}. Supported values: ${supportedValues.toString()}`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
getOptionalValidated(param, defaultValue, validator) {
|
|
149
|
+
const value = this.env[param] || defaultValue;
|
|
150
|
+
if (!validator(value)) {
|
|
151
|
+
throw new InternalError({
|
|
152
|
+
message: `Value ${value} is invalid for parameter ${param}`,
|
|
153
|
+
errorCode: "CONFIGURATION_ERROR"
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return value;
|
|
157
|
+
}
|
|
158
|
+
getOptionalValidatedInteger(param, defaultValue, validator) {
|
|
159
|
+
const value = this.getOptionalInteger(param, defaultValue);
|
|
160
|
+
if (!validator(value)) {
|
|
161
|
+
throw new InternalError({
|
|
162
|
+
message: `Value ${value} is invalid for parameter ${param}`,
|
|
163
|
+
errorCode: "CONFIGURATION_ERROR"
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
getOptionalTransformed(param, defaultValue, transformer) {
|
|
169
|
+
const value = this.env[param] || defaultValue;
|
|
170
|
+
return transformer(value);
|
|
171
|
+
}
|
|
172
|
+
getOptionalNullableTransformed(param, defaultValue, transformer) {
|
|
173
|
+
const value = this.env[param] || defaultValue;
|
|
174
|
+
return transformer(value);
|
|
175
|
+
}
|
|
176
|
+
getMandatoryTransformed(param, transformer) {
|
|
177
|
+
const value = this.getMandatory(param);
|
|
178
|
+
return transformer(value);
|
|
179
|
+
}
|
|
180
|
+
getOptionalBoolean(param, defaultValue) {
|
|
181
|
+
const rawValue = this.env[param]?.toLowerCase();
|
|
182
|
+
if (rawValue === void 0 || rawValue === "") {
|
|
183
|
+
return defaultValue;
|
|
184
|
+
}
|
|
185
|
+
validateOneOf(rawValue, ["true", "false"]);
|
|
186
|
+
return rawValue === "true";
|
|
187
|
+
}
|
|
188
|
+
getMandatoryJsonObject(param, schema) {
|
|
189
|
+
const rawValue = this.getMandatory(param);
|
|
190
|
+
return this.validateSchema(
|
|
191
|
+
JSON.parse(rawValue),
|
|
192
|
+
schema,
|
|
193
|
+
`Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
getOptionalNullableJsonObject(param, schema, defaultValue) {
|
|
197
|
+
const rawValue = this.getOptionalNullable(param, void 0);
|
|
198
|
+
if (!rawValue) {
|
|
199
|
+
return defaultValue;
|
|
200
|
+
}
|
|
201
|
+
return this.validateSchema(
|
|
202
|
+
JSON.parse(rawValue),
|
|
203
|
+
schema,
|
|
204
|
+
`Configuration parameter ${param} must be a valid JSON meeting the given schema, but was ${rawValue}`
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
getOptionalJsonObject(param, schema, defaultValue) {
|
|
208
|
+
return this.getOptionalNullableJsonObject(param, schema, defaultValue);
|
|
209
|
+
}
|
|
210
|
+
isProduction() {
|
|
211
|
+
return this.env.NODE_ENV === "production";
|
|
212
|
+
}
|
|
213
|
+
isDevelopment() {
|
|
214
|
+
return this.env.NODE_ENV !== "production";
|
|
215
|
+
}
|
|
216
|
+
isTest() {
|
|
217
|
+
return this.env.NODE_ENV === "test";
|
|
218
|
+
}
|
|
219
|
+
validateSchema(value, schema, errorMessage) {
|
|
220
|
+
const parsedValue = schema.safeParse(value);
|
|
221
|
+
if (!parsedValue.success) {
|
|
222
|
+
throw new InternalError({
|
|
223
|
+
message: errorMessage,
|
|
224
|
+
errorCode: "CONFIGURATION_ERROR",
|
|
225
|
+
details: parsedValue.error
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return parsedValue.data;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
function validateOneOf(validatedEntity, expectedOneOfEntities, errorText) {
|
|
232
|
+
if (!expectedOneOfEntities.includes(validatedEntity)) {
|
|
233
|
+
throw new InternalError({
|
|
234
|
+
message: errorText || // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
235
|
+
`Validated entity ${validatedEntity} is not one of: ${expectedOneOfEntities.toString()}`,
|
|
236
|
+
errorCode: "CONFIGURATION_ERROR"
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return validatedEntity;
|
|
240
|
+
}
|
|
241
|
+
function validateNumber(validatedObject, errorText) {
|
|
242
|
+
if (!Number.isFinite(validatedObject)) {
|
|
243
|
+
throw new InternalError({
|
|
244
|
+
message: errorText,
|
|
245
|
+
errorCode: "CONFIGURATION_ERROR"
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return validatedObject;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// src/config/configTransformers.ts
|
|
252
|
+
var ensureClosingSlashTransformer = (value) => {
|
|
253
|
+
if (!value) {
|
|
254
|
+
return "";
|
|
255
|
+
}
|
|
256
|
+
const lastChar = value.at(-1);
|
|
257
|
+
if (lastChar !== "/") {
|
|
258
|
+
return `${value}/`;
|
|
259
|
+
}
|
|
260
|
+
return value;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// src/config/configValidators.ts
|
|
264
|
+
var createRangeValidator = (greaterOrEqualThan, lessOrEqualThan) => {
|
|
265
|
+
return (value) => {
|
|
266
|
+
return value >= greaterOrEqualThan && value <= lessOrEqualThan;
|
|
267
|
+
};
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
// src/errors/either.ts
|
|
271
|
+
var isFailure = (e) => {
|
|
272
|
+
return e.error !== void 0;
|
|
273
|
+
};
|
|
274
|
+
var isSuccess = (e) => {
|
|
275
|
+
return e.result !== void 0;
|
|
276
|
+
};
|
|
277
|
+
var failure = (error) => ({ error });
|
|
278
|
+
var success = (result) => ({ result });
|
|
279
|
+
|
|
280
|
+
// src/utils/encryptionUtility.ts
|
|
281
|
+
import * as crypto from "node:crypto";
|
|
282
|
+
var algorithm = "aes-256-gcm";
|
|
283
|
+
var ivLength = 16;
|
|
284
|
+
var tagLength = 16;
|
|
285
|
+
var defaultEncoding = "hex";
|
|
286
|
+
var defaultSaltLength = 64;
|
|
287
|
+
var defaultPbkdf2Iterations = 1e5;
|
|
288
|
+
var EncryptionUtility = class {
|
|
289
|
+
secret;
|
|
290
|
+
saltLength;
|
|
291
|
+
encryptedPosition;
|
|
292
|
+
tagPosition;
|
|
293
|
+
pbkdf2Iterations;
|
|
294
|
+
encoding;
|
|
295
|
+
constructor(secret, options) {
|
|
296
|
+
this.secret = secret;
|
|
297
|
+
this.encoding = options?.encoding ?? defaultEncoding;
|
|
298
|
+
this.pbkdf2Iterations = options?.pbkdf2Iterations ?? defaultPbkdf2Iterations;
|
|
299
|
+
this.saltLength = options?.saltLength ?? defaultSaltLength;
|
|
300
|
+
this.tagPosition = this.saltLength + ivLength;
|
|
301
|
+
this.encryptedPosition = this.tagPosition + tagLength;
|
|
302
|
+
}
|
|
303
|
+
getKey(salt) {
|
|
304
|
+
return crypto.pbkdf2Sync(this.secret, salt, this.pbkdf2Iterations, 32, "sha512");
|
|
305
|
+
}
|
|
306
|
+
encrypt(value) {
|
|
307
|
+
const iv = crypto.randomBytes(ivLength);
|
|
308
|
+
const salt = crypto.randomBytes(this.saltLength);
|
|
309
|
+
const key = this.getKey(salt);
|
|
310
|
+
const cipher = crypto.createCipheriv(algorithm, key, iv);
|
|
311
|
+
const encrypted = Buffer.concat([cipher.update(String(value), "utf8"), cipher.final()]);
|
|
312
|
+
const tag = cipher.getAuthTag();
|
|
313
|
+
return Buffer.concat([salt, iv, tag, encrypted]).toString(this.encoding);
|
|
314
|
+
}
|
|
315
|
+
decrypt(value) {
|
|
316
|
+
const stringValue = Buffer.from(String(value), this.encoding);
|
|
317
|
+
const salt = stringValue.subarray(0, this.saltLength);
|
|
318
|
+
const iv = stringValue.subarray(this.saltLength, this.tagPosition);
|
|
319
|
+
const tag = stringValue.subarray(this.tagPosition, this.encryptedPosition);
|
|
320
|
+
const encrypted = stringValue.subarray(this.encryptedPosition);
|
|
321
|
+
const key = this.getKey(salt);
|
|
322
|
+
const decipher = crypto.createDecipheriv(algorithm, key, iv);
|
|
323
|
+
decipher.setAuthTag(tag);
|
|
324
|
+
return Buffer.concat([
|
|
325
|
+
decipher.update(encrypted),
|
|
326
|
+
Buffer.from(decipher.final("utf8"))
|
|
327
|
+
]).toString("utf8");
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// src/utils/arrayUtils.ts
|
|
332
|
+
function chunk(array, chunkSize) {
|
|
333
|
+
const length = array.length;
|
|
334
|
+
if (!length || chunkSize < 1) {
|
|
335
|
+
return [];
|
|
336
|
+
}
|
|
337
|
+
let index = 0;
|
|
338
|
+
let resIndex = 0;
|
|
339
|
+
const result = new Array(Math.ceil(length / chunkSize));
|
|
340
|
+
while (index < length) {
|
|
341
|
+
result[resIndex++] = array.slice(index, index += chunkSize);
|
|
342
|
+
}
|
|
343
|
+
return result;
|
|
344
|
+
}
|
|
345
|
+
async function callChunked(chunkSize, array, processFn) {
|
|
346
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
347
|
+
const arrayChunk = array.slice(i, i + chunkSize);
|
|
348
|
+
await processFn(arrayChunk);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function removeNullish(array) {
|
|
352
|
+
return array.filter((e) => e !== void 0 && e !== null);
|
|
353
|
+
}
|
|
354
|
+
function removeFalsy(array) {
|
|
355
|
+
return array.filter((e) => e);
|
|
356
|
+
}
|
|
357
|
+
function removeDuplicates(array) {
|
|
358
|
+
return [...new Set(array)];
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// src/utils/objectUtils.ts
|
|
362
|
+
import dotProp from "dot-prop";
|
|
363
|
+
function copyWithoutUndefined(originalValue) {
|
|
364
|
+
return Object.keys(originalValue).reduce(
|
|
365
|
+
(acc, key) => {
|
|
366
|
+
if (originalValue[key] !== void 0) {
|
|
367
|
+
acc[key] = originalValue[key];
|
|
368
|
+
}
|
|
369
|
+
return acc;
|
|
370
|
+
},
|
|
371
|
+
{}
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
function copyWithoutEmpty(originalValue) {
|
|
375
|
+
return Object.keys(originalValue).reduce(
|
|
376
|
+
(acc, key) => {
|
|
377
|
+
if (originalValue[key] !== void 0 && originalValue[key] !== null && // @ts-ignore
|
|
378
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
379
|
+
(typeof originalValue[key] !== "string" || originalValue[key].trim().length > 0)) {
|
|
380
|
+
acc[key] = originalValue[key];
|
|
381
|
+
}
|
|
382
|
+
return acc;
|
|
383
|
+
},
|
|
384
|
+
{}
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
function pick(source, propNames) {
|
|
388
|
+
const result = {};
|
|
389
|
+
let idx = 0;
|
|
390
|
+
while (idx < propNames.length) {
|
|
391
|
+
if (propNames[idx] in source) {
|
|
392
|
+
result[propNames[idx]] = source[propNames[idx]];
|
|
393
|
+
}
|
|
394
|
+
idx += 1;
|
|
395
|
+
}
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
function pickWithoutUndefined(source, propNames) {
|
|
399
|
+
const result = {};
|
|
400
|
+
let idx = 0;
|
|
401
|
+
while (idx < propNames.length) {
|
|
402
|
+
if (propNames[idx] in source && source[propNames[idx]] !== void 0) {
|
|
403
|
+
result[propNames[idx]] = source[propNames[idx]];
|
|
404
|
+
}
|
|
405
|
+
idx += 1;
|
|
406
|
+
}
|
|
407
|
+
return result;
|
|
408
|
+
}
|
|
409
|
+
function isEmptyObject(params) {
|
|
410
|
+
for (const key in params) {
|
|
411
|
+
if (Object.hasOwn(params, key) && params[key] !== void 0) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
function groupBy(array, selector) {
|
|
418
|
+
return array.reduce(
|
|
419
|
+
(acc, item) => {
|
|
420
|
+
const key = item[selector];
|
|
421
|
+
if (key === void 0 || key === null) {
|
|
422
|
+
return acc;
|
|
423
|
+
}
|
|
424
|
+
if (!acc[key]) {
|
|
425
|
+
acc[key] = [];
|
|
426
|
+
}
|
|
427
|
+
acc[key].push(item);
|
|
428
|
+
return acc;
|
|
429
|
+
},
|
|
430
|
+
{}
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
function groupByPath(array, selector) {
|
|
434
|
+
return array.reduce(
|
|
435
|
+
(acc, item) => {
|
|
436
|
+
const key = dotProp.get(item, selector);
|
|
437
|
+
if (key === void 0 || key === null) {
|
|
438
|
+
return acc;
|
|
439
|
+
}
|
|
440
|
+
const strKeyPath = key;
|
|
441
|
+
if (!acc[strKeyPath]) {
|
|
442
|
+
acc[strKeyPath] = [];
|
|
443
|
+
}
|
|
444
|
+
acc[strKeyPath].push(item);
|
|
445
|
+
return acc;
|
|
446
|
+
},
|
|
447
|
+
{}
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
function groupByUnique(array, selector) {
|
|
451
|
+
return array.reduce(
|
|
452
|
+
(acc, item) => {
|
|
453
|
+
const key = item[selector];
|
|
454
|
+
if (key === void 0 || key === null) {
|
|
455
|
+
return acc;
|
|
456
|
+
}
|
|
457
|
+
if (acc[key] !== void 0) {
|
|
458
|
+
throw new InternalError({
|
|
459
|
+
message: `Duplicated item for selector ${selector.toString()} with value ${key.toString()}`,
|
|
460
|
+
errorCode: "DUPLICATED_ITEM",
|
|
461
|
+
details: { selector, value: key }
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
acc[key] = item;
|
|
465
|
+
return acc;
|
|
466
|
+
},
|
|
467
|
+
{}
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
function convertDateFieldsToIsoString(object) {
|
|
471
|
+
if (Array.isArray(object)) {
|
|
472
|
+
return object.map(convertDateFieldsToIsoStringAux);
|
|
473
|
+
}
|
|
474
|
+
return Object.entries(object).reduce(
|
|
475
|
+
(result, [key, value]) => {
|
|
476
|
+
result[key] = convertDateFieldsToIsoStringAux(value);
|
|
477
|
+
return result;
|
|
478
|
+
},
|
|
479
|
+
{}
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
function convertDateFieldsToIsoStringAux(item) {
|
|
483
|
+
if (item instanceof Date) {
|
|
484
|
+
return item.toISOString();
|
|
485
|
+
}
|
|
486
|
+
if (item && typeof item === "object") {
|
|
487
|
+
return convertDateFieldsToIsoString(item);
|
|
488
|
+
}
|
|
489
|
+
return item;
|
|
490
|
+
}
|
|
491
|
+
function deepClone(object) {
|
|
492
|
+
if (object === void 0 || object === null) {
|
|
493
|
+
return object;
|
|
494
|
+
}
|
|
495
|
+
return structuredClone(object);
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
// src/utils/hashUtils.ts
|
|
499
|
+
import { createHash } from "node:crypto";
|
|
500
|
+
var HashEncoding = /* @__PURE__ */ ((HashEncoding2) => {
|
|
501
|
+
HashEncoding2["HEX"] = "hex";
|
|
502
|
+
HashEncoding2["BASE64"] = "base64";
|
|
503
|
+
return HashEncoding2;
|
|
504
|
+
})(HashEncoding || {});
|
|
505
|
+
var HashAlgorithm = /* @__PURE__ */ ((HashAlgorithm2) => {
|
|
506
|
+
HashAlgorithm2["SHA256"] = "sha256";
|
|
507
|
+
HashAlgorithm2["SHA512"] = "sha512";
|
|
508
|
+
return HashAlgorithm2;
|
|
509
|
+
})(HashAlgorithm || {});
|
|
510
|
+
function generateHash(algorithm2, data, encoding = "hex" /* HEX */) {
|
|
511
|
+
return createHash(algorithm2).update(data).digest(encoding);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// src/logging/loggerConfigResolver.ts
|
|
515
|
+
import { levels, pino } from "pino";
|
|
516
|
+
import pretty from "pino-pretty";
|
|
517
|
+
function resolveMonorepoLogger(appConfig) {
|
|
518
|
+
if (appConfig.nodeEnv !== "development") {
|
|
519
|
+
return resolveLogger(appConfig);
|
|
520
|
+
}
|
|
521
|
+
const configuration = resolveMonorepoLoggerConfiguration(appConfig);
|
|
522
|
+
return pino(configuration);
|
|
523
|
+
}
|
|
524
|
+
function resolveMonorepoLoggerConfiguration(appConfig) {
|
|
525
|
+
if (appConfig.nodeEnv !== "development") {
|
|
526
|
+
return resolveLoggerConfiguration(appConfig);
|
|
527
|
+
}
|
|
528
|
+
return {
|
|
529
|
+
level: appConfig.logLevel,
|
|
530
|
+
formatters: {
|
|
531
|
+
level: (label) => {
|
|
532
|
+
return { level: label };
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
redact: appConfig.redact,
|
|
536
|
+
transport: {
|
|
537
|
+
target: "pino/file",
|
|
538
|
+
options: {
|
|
539
|
+
destination: appConfig.targetFile ?? "./service.log",
|
|
540
|
+
mkdir: true,
|
|
541
|
+
append: appConfig.append ?? false
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function resolveLogger(appConfig) {
|
|
547
|
+
if (appConfig.nodeEnv !== "production") {
|
|
548
|
+
return resolveLoggerConfiguration(appConfig);
|
|
549
|
+
}
|
|
550
|
+
const configuration = resolveLoggerConfiguration(appConfig);
|
|
551
|
+
return pino(configuration);
|
|
552
|
+
}
|
|
553
|
+
function resolveLoggerConfiguration(appConfig) {
|
|
554
|
+
if (appConfig.nodeEnv !== "production") {
|
|
555
|
+
return pino(
|
|
556
|
+
pretty({
|
|
557
|
+
sync: true,
|
|
558
|
+
minimumLevel: appConfig.logLevel,
|
|
559
|
+
colorize: true,
|
|
560
|
+
translateTime: "SYS:standard",
|
|
561
|
+
ignore: "hostname,pid"
|
|
562
|
+
})
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
return {
|
|
566
|
+
level: appConfig.logLevel,
|
|
567
|
+
formatters: {
|
|
568
|
+
level: (_label, numericLevel) => {
|
|
569
|
+
const level = levels.labels[numericLevel] || "unknown";
|
|
570
|
+
return { level };
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
redact: appConfig.redact
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// src/errors/globalErrorHandler.ts
|
|
578
|
+
import { types } from "node:util";
|
|
579
|
+
import { levels as levels2, pino as pino2, stdSerializers } from "pino";
|
|
580
|
+
var globalLogger = pino2({
|
|
581
|
+
formatters: {
|
|
582
|
+
level: (_label, numericLevel) => {
|
|
583
|
+
const level = levels2.labels[numericLevel] || "unknown";
|
|
584
|
+
return { level };
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
function resolveGlobalErrorLogObject(err, correlationId) {
|
|
589
|
+
if (types.isNativeError(err)) {
|
|
590
|
+
return {
|
|
591
|
+
message: err.message,
|
|
592
|
+
error: stdSerializers.err(err),
|
|
593
|
+
"x-request-id": correlationId
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
if (hasMessage(err)) {
|
|
597
|
+
return {
|
|
598
|
+
message: err.message,
|
|
599
|
+
"x-request-id": correlationId
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
return {
|
|
603
|
+
message: "Unknown error",
|
|
604
|
+
"x-request-id": correlationId
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
function executeAndHandleGlobalErrors(operation) {
|
|
608
|
+
try {
|
|
609
|
+
const result = operation();
|
|
610
|
+
return result;
|
|
611
|
+
} catch (err) {
|
|
612
|
+
const logObject = resolveGlobalErrorLogObject(err);
|
|
613
|
+
globalLogger.error(logObject, logObject.message);
|
|
614
|
+
process.exit(1);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
async function executeAsyncAndHandleGlobalErrors(operation, stopOnError = true) {
|
|
618
|
+
try {
|
|
619
|
+
const result = await operation();
|
|
620
|
+
return result;
|
|
621
|
+
} catch (err) {
|
|
622
|
+
const logObject = resolveGlobalErrorLogObject(err);
|
|
623
|
+
globalLogger.error(logObject, logObject.message);
|
|
624
|
+
if (stopOnError) {
|
|
625
|
+
process.exit(1);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
async function executeSettleAllAndHandleGlobalErrors(promises, stopOnError = true) {
|
|
630
|
+
const result = await Promise.allSettled(promises);
|
|
631
|
+
let errorsHappened;
|
|
632
|
+
for (const entry of result) {
|
|
633
|
+
if (entry.status === "rejected") {
|
|
634
|
+
const logObject = resolveGlobalErrorLogObject(entry.reason);
|
|
635
|
+
globalLogger.error(logObject, logObject.message);
|
|
636
|
+
errorsHappened = true;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (stopOnError && errorsHappened) {
|
|
640
|
+
process.exit(1);
|
|
641
|
+
}
|
|
642
|
+
return result;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// src/errors/publicErrors.ts
|
|
646
|
+
import { constants as httpConstants } from "node:http2";
|
|
647
|
+
var RequestValidationError = class extends PublicNonRecoverableError {
|
|
648
|
+
constructor(errors) {
|
|
649
|
+
super({
|
|
650
|
+
message: "Invalid params",
|
|
651
|
+
errorCode: "VALIDATION_ERROR",
|
|
652
|
+
httpStatusCode: httpConstants.HTTP_STATUS_BAD_REQUEST,
|
|
653
|
+
details: {
|
|
654
|
+
error: errors
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
var AccessDeniedError = class extends PublicNonRecoverableError {
|
|
660
|
+
constructor(params) {
|
|
661
|
+
super({
|
|
662
|
+
message: params.message,
|
|
663
|
+
errorCode: "ACCESS_DENIED",
|
|
664
|
+
httpStatusCode: httpConstants.HTTP_STATUS_FORBIDDEN,
|
|
665
|
+
details: params.details,
|
|
666
|
+
cause: params.cause
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
var EntityNotFoundError = class extends PublicNonRecoverableError {
|
|
671
|
+
constructor(params) {
|
|
672
|
+
super({
|
|
673
|
+
message: params.message,
|
|
674
|
+
errorCode: "ENTITY_NOT_FOUND",
|
|
675
|
+
httpStatusCode: httpConstants.HTTP_STATUS_NOT_FOUND,
|
|
676
|
+
details: params.details,
|
|
677
|
+
cause: params.cause
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
var EntityGoneError = class extends PublicNonRecoverableError {
|
|
682
|
+
constructor(params) {
|
|
683
|
+
super({
|
|
684
|
+
message: params.message,
|
|
685
|
+
errorCode: "ENTITY_GONE",
|
|
686
|
+
httpStatusCode: 410,
|
|
687
|
+
details: params.details
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
};
|
|
691
|
+
var AuthFailedError = class extends PublicNonRecoverableError {
|
|
692
|
+
constructor(params = {}) {
|
|
693
|
+
super({
|
|
694
|
+
message: params.message ?? "Authentication failed",
|
|
695
|
+
errorCode: "AUTH_FAILED",
|
|
696
|
+
httpStatusCode: httpConstants.HTTP_STATUS_UNAUTHORIZED,
|
|
697
|
+
details: params.details,
|
|
698
|
+
cause: params.cause
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
// src/utils/waitUtils.ts
|
|
704
|
+
var waitAndRetry = async (predicateFn, sleepTime = 20, maxRetryCount = 15) => {
|
|
705
|
+
return new Promise((resolve, reject) => {
|
|
706
|
+
let retryCount = 0;
|
|
707
|
+
function performCheck() {
|
|
708
|
+
if (maxRetryCount !== 0 && retryCount > maxRetryCount) {
|
|
709
|
+
resolve(predicateFn());
|
|
710
|
+
}
|
|
711
|
+
Promise.resolve().then(() => {
|
|
712
|
+
return predicateFn();
|
|
713
|
+
}).then((result) => {
|
|
714
|
+
if (result) {
|
|
715
|
+
resolve(result);
|
|
716
|
+
} else {
|
|
717
|
+
retryCount++;
|
|
718
|
+
setTimeout(performCheck, sleepTime);
|
|
719
|
+
}
|
|
720
|
+
}).catch((err) => {
|
|
721
|
+
reject(err);
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
performCheck();
|
|
725
|
+
});
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
// src/observability/MultiTransactionObservabilityManager.ts
|
|
729
|
+
var MultiTransactionObservabilityManager = class {
|
|
730
|
+
managers;
|
|
731
|
+
constructor(managers) {
|
|
732
|
+
this.managers = managers;
|
|
733
|
+
}
|
|
734
|
+
start(transactionName, uniqueTransactionKey) {
|
|
735
|
+
for (const manager of this.managers) {
|
|
736
|
+
manager.start(transactionName, uniqueTransactionKey);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
startWithGroup(transactionName, uniqueTransactionKey, transactionGroup) {
|
|
740
|
+
for (const manager of this.managers) {
|
|
741
|
+
manager.startWithGroup(transactionName, uniqueTransactionKey, transactionGroup);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
stop(uniqueTransactionKey, wasSuccessful) {
|
|
745
|
+
for (const manager of this.managers) {
|
|
746
|
+
manager.stop(uniqueTransactionKey, wasSuccessful);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
// src/utils/checksumUtils.ts
|
|
752
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
753
|
+
var HASH_ALGORITHM = "md5";
|
|
754
|
+
function generateChecksumForBufferOrString(data) {
|
|
755
|
+
return createHash2(HASH_ALGORITHM).update(data).digest("hex");
|
|
756
|
+
}
|
|
757
|
+
function generateChecksumForObject(object) {
|
|
758
|
+
const objectAsString = JSON.stringify(object);
|
|
759
|
+
return generateChecksumForBufferOrString(objectAsString);
|
|
760
|
+
}
|
|
761
|
+
function generateChecksumForReadable(readable) {
|
|
762
|
+
return new Promise((resolve, reject) => {
|
|
763
|
+
const hashCreator = createHash2(HASH_ALGORITHM);
|
|
764
|
+
readable.on("data", (data) => {
|
|
765
|
+
if (Buffer.isBuffer(data)) {
|
|
766
|
+
hashCreator.update(data);
|
|
767
|
+
} else {
|
|
768
|
+
hashCreator.update(Buffer.from(data));
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
readable.on("end", () => {
|
|
772
|
+
const hash = hashCreator.digest("hex");
|
|
773
|
+
resolve(hash);
|
|
774
|
+
});
|
|
775
|
+
readable.on("error", (err) => {
|
|
776
|
+
reject(err);
|
|
777
|
+
});
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// src/utils/streamUtils.ts
|
|
782
|
+
import { F_OK } from "node:constants";
|
|
783
|
+
import { access, createReadStream, createWriteStream } from "node:fs";
|
|
784
|
+
import { stat, unlink } from "node:fs/promises";
|
|
785
|
+
import { pipeline } from "node:stream";
|
|
786
|
+
var FsReadableProvider = class _FsReadableProvider {
|
|
787
|
+
storageFile;
|
|
788
|
+
constructor(options) {
|
|
789
|
+
this.storageFile = options.storageFile;
|
|
790
|
+
}
|
|
791
|
+
fileExists() {
|
|
792
|
+
return new Promise((resolve) => {
|
|
793
|
+
access(this.storageFile, F_OK, (err) => {
|
|
794
|
+
return resolve(!err);
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
async getContentLength() {
|
|
799
|
+
if (!await this.fileExists()) {
|
|
800
|
+
throw new Error(`File ${this.storageFile} was already deleted.`);
|
|
801
|
+
}
|
|
802
|
+
const stats = await stat(this.storageFile);
|
|
803
|
+
return stats.size;
|
|
804
|
+
}
|
|
805
|
+
async createStream() {
|
|
806
|
+
if (!await this.fileExists()) {
|
|
807
|
+
throw new Error(`File ${this.storageFile} was already deleted.`);
|
|
808
|
+
}
|
|
809
|
+
return createReadStream(this.storageFile);
|
|
810
|
+
}
|
|
811
|
+
async destroy() {
|
|
812
|
+
if (!await this.fileExists()) {
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
return unlink(this.storageFile);
|
|
816
|
+
}
|
|
817
|
+
async persist(sourceReadable) {
|
|
818
|
+
const writable = createWriteStream(this.storageFile);
|
|
819
|
+
return new Promise((resolve, reject) => {
|
|
820
|
+
pipeline(sourceReadable, writable, (err) => {
|
|
821
|
+
if (err) {
|
|
822
|
+
reject(err);
|
|
823
|
+
} else {
|
|
824
|
+
resolve();
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
static async persistReadableToFs(options) {
|
|
830
|
+
const provider = new _FsReadableProvider({
|
|
831
|
+
storageFile: options.targetFile
|
|
832
|
+
});
|
|
833
|
+
await provider.persist(options.sourceReadable);
|
|
834
|
+
return provider;
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
export {
|
|
838
|
+
AccessDeniedError,
|
|
839
|
+
AuthFailedError,
|
|
840
|
+
ConfigScope,
|
|
841
|
+
EncryptionUtility,
|
|
842
|
+
EntityGoneError,
|
|
843
|
+
EntityNotFoundError,
|
|
844
|
+
FsReadableProvider,
|
|
845
|
+
HashAlgorithm,
|
|
846
|
+
HashEncoding,
|
|
847
|
+
InternalError,
|
|
848
|
+
MultiTransactionObservabilityManager,
|
|
849
|
+
PublicNonRecoverableError,
|
|
850
|
+
RequestValidationError,
|
|
851
|
+
callChunked,
|
|
852
|
+
chunk,
|
|
853
|
+
convertDateFieldsToIsoString,
|
|
854
|
+
copyWithoutEmpty,
|
|
855
|
+
copyWithoutUndefined,
|
|
856
|
+
createRangeValidator,
|
|
857
|
+
deepClone,
|
|
858
|
+
ensureClosingSlashTransformer,
|
|
859
|
+
executeAndHandleGlobalErrors,
|
|
860
|
+
executeAsyncAndHandleGlobalErrors,
|
|
861
|
+
executeSettleAllAndHandleGlobalErrors,
|
|
862
|
+
failure,
|
|
863
|
+
generateChecksumForBufferOrString,
|
|
864
|
+
generateChecksumForObject,
|
|
865
|
+
generateChecksumForReadable,
|
|
866
|
+
generateHash,
|
|
867
|
+
globalLogger,
|
|
868
|
+
groupBy,
|
|
869
|
+
groupByPath,
|
|
870
|
+
groupByUnique,
|
|
871
|
+
hasMessage,
|
|
872
|
+
isEmptyObject,
|
|
873
|
+
isEntityGoneError,
|
|
874
|
+
isError,
|
|
875
|
+
isFailure,
|
|
876
|
+
isInternalError,
|
|
877
|
+
isObject,
|
|
878
|
+
isPublicNonRecoverableError,
|
|
879
|
+
isStandardizedError,
|
|
880
|
+
isSuccess,
|
|
881
|
+
pick,
|
|
882
|
+
pickWithoutUndefined,
|
|
883
|
+
removeDuplicates,
|
|
884
|
+
removeFalsy,
|
|
885
|
+
removeNullish,
|
|
886
|
+
resolveGlobalErrorLogObject,
|
|
887
|
+
resolveLogger,
|
|
888
|
+
resolveLoggerConfiguration,
|
|
889
|
+
resolveMonorepoLogger,
|
|
890
|
+
resolveMonorepoLoggerConfiguration,
|
|
891
|
+
success,
|
|
892
|
+
waitAndRetry
|
|
893
|
+
};
|
|
79
894
|
//# sourceMappingURL=index.js.map
|