@lokalise/node-core 9.22.0 → 10.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/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. Default is 30 seconds. Pass `undefined` if you prefer to have no timeout;
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:
@@ -239,3 +179,11 @@ expect(someEventEmitter.emittedEvents.length).toBe(1)
239
179
  ## Hashing
240
180
 
241
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,8 +1,6 @@
1
- export { sendPut, sendPutBinary, sendDelete, sendPatch, sendGet, sendPost, sendPostBinary, httpClient, buildClient, type RequestOptions, type Response, type HttpRequestContext, type ResponseSchema, JSON_HEADERS, } 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 { ResponseStatusError } from './src/errors/ResponseStatusError';
5
- export { isResponseStatusError, isEntityGoneError } 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';
@@ -23,6 +21,7 @@ export { type MayOmit } from './src/common/may-omit';
23
21
  export { type FreeformRecord } from './src/common/commonTypes';
24
22
  export { type ValidationError, type CommonErrorParams, type OptionalMessageErrorParams, RequestValidationError, AccessDeniedError, EntityNotFoundError, EntityGoneError, AuthFailedError, } from './src/errors/publicErrors';
25
23
  export { waitAndRetry } from './src/utils/waitUtils';
26
- export * from './src/observability/observabilityTypes';
27
- export * from './src/utils/checksumUtils';
28
- export * from './src/utils/streamUtils';
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,27 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.isResponseStatusError = exports.ResponseStatusError = exports.InternalError = exports.PublicNonRecoverableError = exports.JSON_HEADERS = exports.buildClient = exports.httpClient = exports.sendPostBinary = exports.sendPost = exports.sendGet = exports.sendPatch = exports.sendDelete = exports.sendPutBinary = exports.sendPut = void 0;
4
- exports.waitAndRetry = exports.AuthFailedError = exports.EntityGoneError = exports.EntityNotFoundError = exports.AccessDeniedError = exports.RequestValidationError = exports.resolveGlobalErrorLogObject = exports.globalLogger = exports.executeSettleAllAndHandleGlobalErrors = void 0;
5
- const tslib_1 = require("tslib");
6
- var httpClient_1 = require("./src/http/httpClient");
7
- Object.defineProperty(exports, "sendPut", { enumerable: true, get: function () { return httpClient_1.sendPut; } });
8
- Object.defineProperty(exports, "sendPutBinary", { enumerable: true, get: function () { return httpClient_1.sendPutBinary; } });
9
- Object.defineProperty(exports, "sendDelete", { enumerable: true, get: function () { return httpClient_1.sendDelete; } });
10
- Object.defineProperty(exports, "sendPatch", { enumerable: true, get: function () { return httpClient_1.sendPatch; } });
11
- Object.defineProperty(exports, "sendGet", { enumerable: true, get: function () { return httpClient_1.sendGet; } });
12
- Object.defineProperty(exports, "sendPost", { enumerable: true, get: function () { return httpClient_1.sendPost; } });
13
- Object.defineProperty(exports, "sendPostBinary", { enumerable: true, get: function () { return httpClient_1.sendPostBinary; } });
14
- Object.defineProperty(exports, "httpClient", { enumerable: true, get: function () { return httpClient_1.httpClient; } });
15
- Object.defineProperty(exports, "buildClient", { enumerable: true, get: function () { return httpClient_1.buildClient; } });
16
- Object.defineProperty(exports, "JSON_HEADERS", { enumerable: true, get: function () { return httpClient_1.JSON_HEADERS; } });
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;
17
5
  var PublicNonRecoverableError_1 = require("./src/errors/PublicNonRecoverableError");
18
6
  Object.defineProperty(exports, "PublicNonRecoverableError", { enumerable: true, get: function () { return PublicNonRecoverableError_1.PublicNonRecoverableError; } });
19
7
  var InternalError_1 = require("./src/errors/InternalError");
20
8
  Object.defineProperty(exports, "InternalError", { enumerable: true, get: function () { return InternalError_1.InternalError; } });
21
- var ResponseStatusError_1 = require("./src/errors/ResponseStatusError");
22
- Object.defineProperty(exports, "ResponseStatusError", { enumerable: true, get: function () { return ResponseStatusError_1.ResponseStatusError; } });
23
9
  var errorTypeGuards_1 = require("./src/errors/errorTypeGuards");
24
- Object.defineProperty(exports, "isResponseStatusError", { enumerable: true, get: function () { return errorTypeGuards_1.isResponseStatusError; } });
25
10
  Object.defineProperty(exports, "isEntityGoneError", { enumerable: true, get: function () { return errorTypeGuards_1.isEntityGoneError; } });
26
11
  var ConfigScope_1 = require("./src/config/ConfigScope");
27
12
  Object.defineProperty(exports, "ConfigScope", { enumerable: true, get: function () { return ConfigScope_1.ConfigScope; } });
@@ -80,7 +65,10 @@ Object.defineProperty(exports, "EntityGoneError", { enumerable: true, get: funct
80
65
  Object.defineProperty(exports, "AuthFailedError", { enumerable: true, get: function () { return publicErrors_1.AuthFailedError; } });
81
66
  var waitUtils_1 = require("./src/utils/waitUtils");
82
67
  Object.defineProperty(exports, "waitAndRetry", { enumerable: true, get: function () { return waitUtils_1.waitAndRetry; } });
83
- tslib_1.__exportStar(require("./src/observability/observabilityTypes"), exports);
84
- tslib_1.__exportStar(require("./src/utils/checksumUtils"), exports);
85
- tslib_1.__exportStar(require("./src/utils/streamUtils"), exports);
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; } });
86
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":";;;;;AAAA,oDAe8B;AAd5B,qGAAA,OAAO,OAAA;AACP,2GAAA,aAAa,OAAA;AACb,wGAAA,UAAU,OAAA;AACV,uGAAA,SAAS,OAAA;AACT,qGAAA,OAAO,OAAA;AACP,sGAAA,QAAQ,OAAA;AACR,4GAAA,cAAc,OAAA;AACd,wGAAA,UAAU,OAAA;AACV,yGAAA,WAAW,OAAA;AAKX,0GAAA,YAAY,OAAA;AAGd,oFAG+C;AAF7C,sIAAA,yBAAyB,OAAA;AAI3B,4DAImC;AAHjC,8GAAA,aAAa,OAAA;AAIf,wEAAsE;AAA7D,0HAAA,mBAAmB,OAAA;AAC5B,gEAAuF;AAA9E,wHAAA,qBAAqB,OAAA;AAAE,oHAAA,iBAAiB,OAAA;AAEjD,wDAAsD;AAA7C,0GAAA,WAAW,OAAA;AACpB,sEAA+E;AAAtE,mIAAA,6BAA6B,OAAA;AACtC,kEAAoE;AAA3D,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AA0B,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"}
@@ -1,4 +1,2 @@
1
- import type { ResponseStatusError } from './ResponseStatusError';
2
1
  import type { EntityGoneError } from './publicErrors';
3
- export declare function isResponseStatusError(entity: unknown): entity is ResponseStatusError;
4
2
  export declare function isEntityGoneError(entity: unknown): entity is EntityGoneError;
@@ -1,11 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEntityGoneError = exports.isResponseStatusError = void 0;
3
+ exports.isEntityGoneError = void 0;
4
4
  const typeUtils_1 = require("../utils/typeUtils");
5
- function isResponseStatusError(entity) {
6
- return 'isResponseStatusError' in entity;
7
- }
8
- exports.isResponseStatusError = isResponseStatusError;
9
5
  function isEntityGoneError(entity) {
10
6
  return (0, typeUtils_1.isPublicNonRecoverableError)(entity) && entity.httpStatusCode === 410;
11
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errorTypeGuards.js","sourceRoot":"","sources":["../../../src/errors/errorTypeGuards.ts"],"names":[],"mappings":";;;AAAA,kDAAgE;AAKhE,SAAgB,qBAAqB,CAAC,MAAe;IACnD,OAAO,uBAAuB,IAAK,MAA8B,CAAA;AACnE,CAAC;AAFD,sDAEC;AAED,SAAgB,iBAAiB,CAAC,MAAe;IAC/C,OAAO,IAAA,uCAA2B,EAAC,MAAM,CAAC,IAAI,MAAM,CAAC,cAAc,KAAK,GAAG,CAAA;AAC7E,CAAC;AAFD,8CAEC"}
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"}
@@ -31,4 +31,8 @@ export declare class FsReadableProvider implements ReadableProvider {
31
31
  protected persist(sourceReadable: Readable): Promise<void>;
32
32
  static persistReadableToFs(options: PersistToFsOptions): Promise<FsReadableProvider>;
33
33
  }
34
+ /**
35
+ * Consumes the readable in order to calculate its length in bytes
36
+ * @param readable
37
+ */
34
38
  export declare function getReadableContentLength(readable: Readable): Promise<number>;
@@ -60,6 +60,10 @@ class FsReadableProvider {
60
60
  }
61
61
  }
62
62
  exports.FsReadableProvider = FsReadableProvider;
63
+ /**
64
+ * Consumes the readable in order to calculate its length in bytes
65
+ * @param readable
66
+ */
63
67
  function getReadableContentLength(readable) {
64
68
  return new Promise((resolve, reject) => {
65
69
  let size = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"streamUtils.js","sourceRoot":"","sources":["../../../src/utils/streamUtils.ts"],"names":[],"mappings":";;;AAAA,mDAAqC;AACrC,qCAAqE;AACrE,+CAA+C;AAE/C,6CAAsC;AA4BtC,MAAa,kBAAkB;IACb,WAAW,CAAQ;IACnC,YAAY,OAAkC;QAC5C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAA;IACxC,CAAC;IAED,UAAU;QACR,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAA,gBAAM,EAA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CAAC,CAAC,CAAA;QACF,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC7B,sBAAsB;YACtB,MAAM,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAhBD,4DAgBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokalise/node-core",
3
- "version": "9.22.0",
3
+ "version": "10.0.0",
4
4
  "author": {
5
5
  "name": "Lokalise",
6
6
  "url": "https://lokalise.com/"
@@ -37,21 +37,19 @@
37
37
  "dot-prop": "6.0.1",
38
38
  "pino": "^9.1.0",
39
39
  "tslib": "^2.6.2",
40
- "undici": "^6.18.2",
41
- "undici-retry": "^5.0.3",
42
40
  "zod": "^3.23.8"
43
41
  },
44
42
  "devDependencies": {
45
- "@types/node": "^20.12.8",
43
+ "@types/node": "^20.14.2",
46
44
  "@types/tmp": "^0.2.6",
47
- "@typescript-eslint/eslint-plugin": "^7.8.0",
48
- "@typescript-eslint/parser": "^7.8.0",
45
+ "@typescript-eslint/eslint-plugin": "^7.12.0",
46
+ "@typescript-eslint/parser": "^7.12.0",
49
47
  "@vitest/coverage-v8": "1.6.0",
50
48
  "auto-changelog": "^2.4.0",
51
49
  "eslint": "^8.57.0",
52
50
  "eslint-plugin-import": "^2.29.1",
53
51
  "eslint-plugin-vitest": "0.4.1",
54
- "prettier": "^3.2.5",
52
+ "prettier": "^3.3.1",
55
53
  "tmp": "^0.2.3",
56
54
  "typescript": "^5.4.5",
57
55
  "vitest": "1.6.0"
@@ -1,7 +0,0 @@
1
- import type { RequestResult } from 'undici-retry';
2
- import { InternalError } from './InternalError';
3
- export declare class ResponseStatusError extends InternalError {
4
- readonly response: RequestResult<any>;
5
- readonly isResponseStatusError = true;
6
- constructor(requestResult: RequestResult<any>, requestLabel?: string);
7
- }
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResponseStatusError = void 0;
4
- const InternalError_1 = require("./InternalError");
5
- class ResponseStatusError extends InternalError_1.InternalError {
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
- response;
8
- isResponseStatusError = true;
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
- constructor(requestResult, requestLabel = 'N/A') {
11
- super({
12
- message: `Response status code ${requestResult.statusCode}`,
13
- details: {
14
- requestLabel,
15
- response: {
16
- statusCode: requestResult.statusCode,
17
- body: requestResult.body,
18
- },
19
- },
20
- errorCode: 'REQUEST_ERROR',
21
- });
22
- this.response = requestResult;
23
- this.name = 'ResponseStatusError';
24
- }
25
- }
26
- exports.ResponseStatusError = ResponseStatusError;
27
- //# sourceMappingURL=ResponseStatusError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ResponseStatusError.js","sourceRoot":"","sources":["../../../src/errors/ResponseStatusError.ts"],"names":[],"mappings":";;;AAEA,mDAA+C;AAE/C,MAAa,mBAAoB,SAAQ,6BAAa;IACpD,8DAA8D;IAC9C,QAAQ,CAAoB;IAC5B,qBAAqB,GAAG,IAAI,CAAA;IAE5C,8DAA8D;IAC9D,YAAY,aAAiC,EAAE,YAAY,GAAG,KAAK;QACjE,KAAK,CAAC;YACJ,OAAO,EAAE,wBAAwB,aAAa,CAAC,UAAU,EAAE;YAC3D,OAAO,EAAE;gBACP,YAAY;gBACZ,QAAQ,EAAE;oBACR,UAAU,EAAE,aAAa,CAAC,UAAU;oBACpC,IAAI,EAAE,aAAa,CAAC,IAAI;iBACzB;aACF;YACD,SAAS,EAAE,eAAe;SAC3B,CAAC,CAAA;QACF,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF;AArBD,kDAqBC"}
@@ -1,53 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import type { Readable } from 'stream';
4
- import { Client } from 'undici';
5
- import type { FormData } from 'undici';
6
- import type { RequestResult, RetryConfig } from 'undici-retry';
7
- import type { DefiniteEither } from '../errors/either';
8
- type RecordObject = Record<string, any>;
9
- export type HttpRequestContext = {
10
- reqId: string;
11
- };
12
- export type ResponseSchema<Output = any> = {
13
- parse(data: unknown): Output;
14
- };
15
- export type RequestOptions<T> = {
16
- headers?: RecordObject;
17
- query?: RecordObject;
18
- timeout: number | undefined;
19
- throwOnError?: boolean;
20
- reqContext?: HttpRequestContext;
21
- safeParseJson?: boolean;
22
- blobResponseBody?: boolean;
23
- requestLabel: string;
24
- disableKeepAlive?: boolean;
25
- retryConfig?: RetryConfig;
26
- clientOptions?: Client.Options;
27
- responseSchema?: ResponseSchema<T>;
28
- validateResponse: boolean;
29
- };
30
- export type Response<T> = {
31
- body: T;
32
- headers: RecordObject;
33
- statusCode: number;
34
- };
35
- export declare function sendGet<T>(client: Client, path: string, options?: Partial<RequestOptions<T>>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
36
- export declare function sendDelete<T>(client: Client, path: string, options?: Partial<RequestOptions<T>>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
37
- export declare function sendPost<T>(client: Client, path: string, body: RecordObject | undefined, options?: Partial<RequestOptions<T>>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
38
- export declare function sendPostBinary<T>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options?: Partial<RequestOptions<T>>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
39
- export declare function sendPut<T>(client: Client, path: string, body: RecordObject | undefined, options?: Partial<RequestOptions<T>>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
40
- export declare function sendPutBinary<T>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options?: Partial<RequestOptions<T>>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
41
- export declare function sendPatch<T>(client: Client, path: string, body: RecordObject | undefined, options?: Partial<RequestOptions<T>>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
42
- export declare function buildClient(baseUrl: string, clientOptions?: Client.Options): Client;
43
- export declare const httpClient: {
44
- get: typeof sendGet;
45
- post: typeof sendPost;
46
- put: typeof sendPut;
47
- patch: typeof sendPatch;
48
- del: typeof sendDelete;
49
- };
50
- export declare const JSON_HEADERS: {
51
- 'Content-Type': string;
52
- };
53
- export {};
@@ -1,190 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JSON_HEADERS = exports.httpClient = exports.buildClient = exports.sendPatch = exports.sendPutBinary = exports.sendPut = exports.sendPostBinary = exports.sendPost = exports.sendDelete = exports.sendGet = void 0;
4
- const undici_1 = require("undici");
5
- const undici_retry_1 = require("undici-retry");
6
- const ResponseStatusError_1 = require("../errors/ResponseStatusError");
7
- const objectUtils_1 = require("../utils/objectUtils");
8
- const DEFAULT_OPTIONS = {
9
- validateResponse: true,
10
- throwOnError: true,
11
- timeout: 30000,
12
- };
13
- const defaultClientOptions = {
14
- keepAliveMaxTimeout: 300_000,
15
- keepAliveTimeout: 4000,
16
- };
17
- async function sendGet(client, path, options = {}) {
18
- const result = await (0, undici_retry_1.sendWithRetry)(client, {
19
- ...DEFAULT_OPTIONS,
20
- path: path,
21
- method: 'GET',
22
- query: options.query,
23
- headers: (0, objectUtils_1.copyWithoutUndefined)({
24
- 'x-request-id': options.reqContext?.reqId,
25
- ...options.headers,
26
- }),
27
- reset: options.disableKeepAlive ?? false,
28
- bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
29
- headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
30
- throwOnError: false,
31
- }, resolveRetryConfig(options), resolveRequestConfig(options));
32
- return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
33
- }
34
- exports.sendGet = sendGet;
35
- async function sendDelete(client, path, options = {}) {
36
- const result = await (0, undici_retry_1.sendWithRetry)(client, {
37
- ...DEFAULT_OPTIONS,
38
- path,
39
- method: 'DELETE',
40
- query: options.query,
41
- headers: (0, objectUtils_1.copyWithoutUndefined)({
42
- 'x-request-id': options.reqContext?.reqId,
43
- ...options.headers,
44
- }),
45
- reset: options.disableKeepAlive ?? false,
46
- bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
47
- headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
48
- throwOnError: false,
49
- }, resolveRetryConfig(options), resolveRequestConfig(options));
50
- return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
51
- }
52
- exports.sendDelete = sendDelete;
53
- async function sendPost(client, path, body, options = {}) {
54
- const result = await (0, undici_retry_1.sendWithRetry)(client, {
55
- ...DEFAULT_OPTIONS,
56
- path: path,
57
- method: 'POST',
58
- body: body ? JSON.stringify(body) : undefined,
59
- query: options.query,
60
- headers: (0, objectUtils_1.copyWithoutUndefined)({
61
- 'x-request-id': options.reqContext?.reqId,
62
- ...options.headers,
63
- }),
64
- reset: options.disableKeepAlive ?? false,
65
- bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
66
- headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
67
- throwOnError: false,
68
- }, resolveRetryConfig(options), resolveRequestConfig(options));
69
- return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
70
- }
71
- exports.sendPost = sendPost;
72
- async function sendPostBinary(client, path, body, options = {}) {
73
- const result = await (0, undici_retry_1.sendWithRetry)(client, {
74
- ...DEFAULT_OPTIONS,
75
- path: path,
76
- method: 'POST',
77
- body,
78
- query: options.query,
79
- headers: (0, objectUtils_1.copyWithoutUndefined)({
80
- 'x-request-id': options.reqContext?.reqId,
81
- ...options.headers,
82
- }),
83
- reset: options.disableKeepAlive ?? false,
84
- bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
85
- headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
86
- throwOnError: false,
87
- }, resolveRetryConfig(options), resolveRequestConfig(options));
88
- return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
89
- }
90
- exports.sendPostBinary = sendPostBinary;
91
- async function sendPut(client, path, body, options = {}) {
92
- const result = await (0, undici_retry_1.sendWithRetry)(client, {
93
- ...DEFAULT_OPTIONS,
94
- path: path,
95
- method: 'PUT',
96
- body: body ? JSON.stringify(body) : undefined,
97
- query: options.query,
98
- headers: (0, objectUtils_1.copyWithoutUndefined)({
99
- 'x-request-id': options.reqContext?.reqId,
100
- ...options.headers,
101
- }),
102
- reset: options.disableKeepAlive ?? false,
103
- bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
104
- headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
105
- throwOnError: false,
106
- }, resolveRetryConfig(options), resolveRequestConfig(options));
107
- return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
108
- }
109
- exports.sendPut = sendPut;
110
- async function sendPutBinary(client, path, body, options = {}) {
111
- const result = await (0, undici_retry_1.sendWithRetry)(client, {
112
- ...DEFAULT_OPTIONS,
113
- path: path,
114
- method: 'PUT',
115
- body,
116
- query: options.query,
117
- headers: (0, objectUtils_1.copyWithoutUndefined)({
118
- 'x-request-id': options.reqContext?.reqId,
119
- ...options.headers,
120
- }),
121
- reset: options.disableKeepAlive ?? false,
122
- bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
123
- headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
124
- throwOnError: false,
125
- }, resolveRetryConfig(options), resolveRequestConfig(options));
126
- return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
127
- }
128
- exports.sendPutBinary = sendPutBinary;
129
- async function sendPatch(client, path, body, options = {}) {
130
- const result = await (0, undici_retry_1.sendWithRetry)(client, {
131
- ...DEFAULT_OPTIONS,
132
- path: path,
133
- method: 'PATCH',
134
- body: body ? JSON.stringify(body) : undefined,
135
- query: options.query,
136
- headers: (0, objectUtils_1.copyWithoutUndefined)({
137
- 'x-request-id': options.reqContext?.reqId,
138
- ...options.headers,
139
- }),
140
- reset: options.disableKeepAlive ?? false,
141
- bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
142
- headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
143
- throwOnError: false,
144
- }, resolveRetryConfig(options), resolveRequestConfig(options));
145
- return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
146
- }
147
- exports.sendPatch = sendPatch;
148
- function resolveRequestConfig(options) {
149
- return {
150
- safeParseJson: options.safeParseJson ?? false,
151
- blobBody: options.blobResponseBody ?? false,
152
- throwOnInternalError: false,
153
- requestLabel: options.requestLabel,
154
- };
155
- }
156
- function resolveRetryConfig(options) {
157
- return options.retryConfig ?? undici_retry_1.NO_RETRY_CONFIG;
158
- }
159
- function buildClient(baseUrl, clientOptions) {
160
- const newClient = new undici_1.Client(baseUrl, {
161
- ...defaultClientOptions,
162
- ...clientOptions,
163
- });
164
- return newClient;
165
- }
166
- exports.buildClient = buildClient;
167
- function resolveResult(requestResult, throwOnError, validateResponse, validationSchema, requestLabel) {
168
- // Throw response error
169
- if (requestResult.error && throwOnError) {
170
- if ((0, undici_retry_1.isRequestResult)(requestResult.error)) {
171
- throw new ResponseStatusError_1.ResponseStatusError(requestResult.error, requestLabel);
172
- }
173
- throw requestResult.error;
174
- }
175
- if (requestResult.result && validateResponse && validationSchema) {
176
- requestResult.result.body = validationSchema.parse(requestResult.result.body);
177
- }
178
- return requestResult;
179
- }
180
- exports.httpClient = {
181
- get: sendGet,
182
- post: sendPost,
183
- put: sendPut,
184
- patch: sendPatch,
185
- del: sendDelete,
186
- };
187
- exports.JSON_HEADERS = {
188
- 'Content-Type': 'application/json',
189
- };
190
- //# sourceMappingURL=httpClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"httpClient.js","sourceRoot":"","sources":["../../../src/http/httpClient.ts"],"names":[],"mappings":";;;AAEA,mCAA+B;AAE/B,+CAA8E;AAI9E,uEAAmE;AAEnE,sDAA2D;AAgC3D,MAAM,eAAe,GAAG;IACtB,gBAAgB,EAAE,IAAI;IACtB,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,KAAK;CAC4C,CAAA;AAE5D,MAAM,oBAAoB,GAA4B;IACpD,mBAAmB,EAAE,OAAO;IAC5B,gBAAgB,EAAE,IAAI;CACvB,CAAA;AAQM,KAAK,UAAU,OAAO,CAC3B,MAAc,EACd,IAAY,EACZ,UAAsC,EAAE;IAExC,MAAM,MAAM,GAAG,MAAM,IAAA,4BAAa,EAChC,MAAM,EACN;QACE,GAAG,eAAe;QAClB,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,IAAA,kCAAoB,EAAC;YAC5B,cAAc,EAAE,OAAO,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