@lokalise/node-core 12.5.0 → 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.
Files changed (85) hide show
  1. package/dist/index.cjs +985 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +404 -0
  4. package/dist/index.d.ts +404 -29
  5. package/dist/index.js +893 -77
  6. package/dist/index.js.map +1 -1
  7. package/package.json +13 -7
  8. package/dist/src/common/commonTypes.d.ts +0 -1
  9. package/dist/src/common/commonTypes.js +0 -3
  10. package/dist/src/common/commonTypes.js.map +0 -1
  11. package/dist/src/common/may-omit.d.ts +0 -1
  12. package/dist/src/common/may-omit.js +0 -3
  13. package/dist/src/common/may-omit.js.map +0 -1
  14. package/dist/src/config/ConfigScope.d.ts +0 -34
  15. package/dist/src/config/ConfigScope.js +0 -173
  16. package/dist/src/config/ConfigScope.js.map +0 -1
  17. package/dist/src/config/configTransformers.d.ts +0 -2
  18. package/dist/src/config/configTransformers.js +0 -15
  19. package/dist/src/config/configTransformers.js.map +0 -1
  20. package/dist/src/config/configTypes.d.ts +0 -30
  21. package/dist/src/config/configTypes.js +0 -3
  22. package/dist/src/config/configTypes.js.map +0 -1
  23. package/dist/src/config/configValidators.d.ts +0 -2
  24. package/dist/src/config/configValidators.js +0 -10
  25. package/dist/src/config/configValidators.js.map +0 -1
  26. package/dist/src/errors/InternalError.d.ts +0 -16
  27. package/dist/src/errors/InternalError.js +0 -29
  28. package/dist/src/errors/InternalError.js.map +0 -1
  29. package/dist/src/errors/PublicNonRecoverableError.d.ts +0 -21
  30. package/dist/src/errors/PublicNonRecoverableError.js +0 -34
  31. package/dist/src/errors/PublicNonRecoverableError.js.map +0 -1
  32. package/dist/src/errors/either.d.ts +0 -28
  33. package/dist/src/errors/either.js +0 -16
  34. package/dist/src/errors/either.js.map +0 -1
  35. package/dist/src/errors/errorReporterTypes.d.ts +0 -14
  36. package/dist/src/errors/errorReporterTypes.js +0 -3
  37. package/dist/src/errors/errorReporterTypes.js.map +0 -1
  38. package/dist/src/errors/errorTypeGuards.d.ts +0 -2
  39. package/dist/src/errors/errorTypeGuards.js +0 -8
  40. package/dist/src/errors/errorTypeGuards.js.map +0 -1
  41. package/dist/src/errors/globalErrorHandler.d.ts +0 -13
  42. package/dist/src/errors/globalErrorHandler.js +0 -77
  43. package/dist/src/errors/globalErrorHandler.js.map +0 -1
  44. package/dist/src/errors/publicErrors.d.ts +0 -27
  45. package/dist/src/errors/publicErrors.js +0 -66
  46. package/dist/src/errors/publicErrors.js.map +0 -1
  47. package/dist/src/errors/types.d.ts +0 -1
  48. package/dist/src/errors/types.js +0 -3
  49. package/dist/src/errors/types.js.map +0 -1
  50. package/dist/src/logging/commonLogger.d.ts +0 -17
  51. package/dist/src/logging/commonLogger.js +0 -3
  52. package/dist/src/logging/commonLogger.js.map +0 -1
  53. package/dist/src/logging/loggerConfigResolver.d.ts +0 -15
  54. package/dist/src/logging/loggerConfigResolver.js +0 -70
  55. package/dist/src/logging/loggerConfigResolver.js.map +0 -1
  56. package/dist/src/observability/MultiTransactionObservabilityManager.d.ts +0 -12
  57. package/dist/src/observability/MultiTransactionObservabilityManager.js +0 -30
  58. package/dist/src/observability/MultiTransactionObservabilityManager.js.map +0 -1
  59. package/dist/src/observability/observabilityTypes.d.ts +0 -23
  60. package/dist/src/observability/observabilityTypes.js +0 -3
  61. package/dist/src/observability/observabilityTypes.js.map +0 -1
  62. package/dist/src/utils/arrayUtils.d.ts +0 -14
  63. package/dist/src/utils/arrayUtils.js +0 -47
  64. package/dist/src/utils/arrayUtils.js.map +0 -1
  65. package/dist/src/utils/checksumUtils.d.ts +0 -5
  66. package/dist/src/utils/checksumUtils.js +0 -37
  67. package/dist/src/utils/checksumUtils.js.map +0 -1
  68. package/dist/src/utils/encryptionUtility.d.ts +0 -20
  69. package/dist/src/utils/encryptionUtility.js +0 -58
  70. package/dist/src/utils/encryptionUtility.js.map +0 -1
  71. package/dist/src/utils/hashUtils.d.ts +0 -9
  72. package/dist/src/utils/hashUtils.js +0 -19
  73. package/dist/src/utils/hashUtils.js.map +0 -1
  74. package/dist/src/utils/objectUtils.d.ts +0 -55
  75. package/dist/src/utils/objectUtils.js +0 -195
  76. package/dist/src/utils/objectUtils.js.map +0 -1
  77. package/dist/src/utils/streamUtils.d.ts +0 -37
  78. package/dist/src/utils/streamUtils.js +0 -85
  79. package/dist/src/utils/streamUtils.js.map +0 -1
  80. package/dist/src/utils/typeUtils.d.ts +0 -10
  81. package/dist/src/utils/typeUtils.js +0 -19
  82. package/dist/src/utils/typeUtils.js.map +0 -1
  83. package/dist/src/utils/waitUtils.d.ts +0 -1
  84. package/dist/src/utils/waitUtils.js +0 -34
  85. package/dist/src/utils/waitUtils.js.map +0 -1
@@ -1,20 +0,0 @@
1
- export type Options = {
2
- saltLength?: number;
3
- pbkdf2Iterations?: number;
4
- encoding?: NodeJS.BufferEncoding;
5
- };
6
- /**
7
- * Type-scripted version of https://github.com/MauriceButler/cryptr
8
- */
9
- export declare class EncryptionUtility {
10
- private readonly secret;
11
- private readonly saltLength;
12
- private readonly encryptedPosition;
13
- private readonly tagPosition;
14
- private readonly pbkdf2Iterations;
15
- private readonly encoding;
16
- constructor(secret: string, options?: Options);
17
- private getKey;
18
- encrypt(value: string): string;
19
- decrypt(value: string): string;
20
- }
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EncryptionUtility = void 0;
4
- const tslib_1 = require("tslib");
5
- const crypto = tslib_1.__importStar(require("node:crypto"));
6
- const algorithm = 'aes-256-gcm';
7
- const ivLength = 16;
8
- const tagLength = 16;
9
- const defaultEncoding = 'hex';
10
- const defaultSaltLength = 64;
11
- const defaultPbkdf2Iterations = 100000;
12
- /**
13
- * Type-scripted version of https://github.com/MauriceButler/cryptr
14
- */
15
- class EncryptionUtility {
16
- secret;
17
- saltLength;
18
- encryptedPosition;
19
- tagPosition;
20
- pbkdf2Iterations;
21
- encoding;
22
- constructor(secret, options) {
23
- this.secret = secret;
24
- this.encoding = options?.encoding ?? defaultEncoding;
25
- this.pbkdf2Iterations = options?.pbkdf2Iterations ?? defaultPbkdf2Iterations;
26
- this.saltLength = options?.saltLength ?? defaultSaltLength;
27
- this.tagPosition = this.saltLength + ivLength;
28
- this.encryptedPosition = this.tagPosition + tagLength;
29
- }
30
- getKey(salt) {
31
- return crypto.pbkdf2Sync(this.secret, salt, this.pbkdf2Iterations, 32, 'sha512');
32
- }
33
- encrypt(value) {
34
- const iv = crypto.randomBytes(ivLength);
35
- const salt = crypto.randomBytes(this.saltLength);
36
- const key = this.getKey(salt);
37
- const cipher = crypto.createCipheriv(algorithm, key, iv);
38
- const encrypted = Buffer.concat([cipher.update(String(value), 'utf8'), cipher.final()]);
39
- const tag = cipher.getAuthTag();
40
- return Buffer.concat([salt, iv, tag, encrypted]).toString(this.encoding);
41
- }
42
- decrypt(value) {
43
- const stringValue = Buffer.from(String(value), this.encoding);
44
- const salt = stringValue.subarray(0, this.saltLength);
45
- const iv = stringValue.subarray(this.saltLength, this.tagPosition);
46
- const tag = stringValue.subarray(this.tagPosition, this.encryptedPosition);
47
- const encrypted = stringValue.subarray(this.encryptedPosition);
48
- const key = this.getKey(salt);
49
- const decipher = crypto.createDecipheriv(algorithm, key, iv);
50
- decipher.setAuthTag(tag);
51
- return Buffer.concat([
52
- decipher.update(encrypted),
53
- Buffer.from(decipher.final('utf8')),
54
- ]).toString('utf8');
55
- }
56
- }
57
- exports.EncryptionUtility = EncryptionUtility;
58
- //# sourceMappingURL=encryptionUtility.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"encryptionUtility.js","sourceRoot":"","sources":["../../../src/utils/encryptionUtility.ts"],"names":[],"mappings":";;;;AAAA,4DAAqC;AAErC,MAAM,SAAS,GAAG,aAAa,CAAA;AAC/B,MAAM,QAAQ,GAAG,EAAE,CAAA;AACnB,MAAM,SAAS,GAAG,EAAE,CAAA;AACpB,MAAM,eAAe,GAAG,KA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C,QAAQ,CAAC,MAAM,CAAC,CAAA;IACrB,CAAC;CACF;AAxDD,8CAwDC"}
@@ -1,9 +0,0 @@
1
- export declare enum HashEncoding {
2
- HEX = "hex",
3
- BASE64 = "base64"
4
- }
5
- export declare enum HashAlgorithm {
6
- SHA256 = "sha256",
7
- SHA512 = "sha512"
8
- }
9
- export declare function generateHash(algorithm: HashAlgorithm, data: string, encoding?: HashEncoding): string;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HashAlgorithm = exports.HashEncoding = void 0;
4
- exports.generateHash = generateHash;
5
- const node_crypto_1 = require("node:crypto");
6
- var HashEncoding;
7
- (function (HashEncoding) {
8
- HashEncoding["HEX"] = "hex";
9
- HashEncoding["BASE64"] = "base64";
10
- })(HashEncoding || (exports.HashEncoding = HashEncoding = {}));
11
- var HashAlgorithm;
12
- (function (HashAlgorithm) {
13
- HashAlgorithm["SHA256"] = "sha256";
14
- HashAlgorithm["SHA512"] = "sha512";
15
- })(HashAlgorithm || (exports.HashAlgorithm = HashAlgorithm = {}));
16
- function generateHash(algorithm, data, encoding = HashEncoding.HEX) {
17
- return (0, node_crypto_1.createHash)(algorithm).update(data).digest(encoding);
18
- }
19
- //# sourceMappingURL=hashUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hashUtils.js","sourceRoot":"","sources":["../../../src/utils/hashUtils.ts"],"names":[],"mappings":";;;AAYA,oCAMC;AAlBD,6CAAwC;AAExC,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,iCAAiB,CAAA;AACnB,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,kCAAiB,CAAA;AACnB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB;AAED,SAAgB,YAAY,CAC1B,SAAwB,EACxB,IAAY,EACZ,WAAyB,YAAY,CAAC,GAAG;IAEzC,OAAO,IAAA,wBAAU,EAAC,SAAS,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC5D,CAAC"}
@@ -1,55 +0,0 @@
1
- type RecordKeyType = string | number | symbol;
2
- export declare function copyWithoutUndefined<T extends Record<RecordKeyType, unknown>, TargetRecordType = Pick<T, {
3
- [Prop in keyof T]: T[Prop] extends null | undefined ? never : Prop;
4
- }[keyof T]>>(originalValue: T): TargetRecordType;
5
- export declare function copyWithoutEmpty<T extends Record<RecordKeyType, unknown>, TargetRecordType = Pick<T, {
6
- [Prop in keyof T]: T[Prop] extends null | undefined | '' ? never : Prop;
7
- }[keyof T]>>(originalValue: T): TargetRecordType;
8
- export declare function pick<T, K extends string | number | symbol>(source: T, propNames: readonly K[]): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
9
- export declare function pickWithoutUndefined<T, K extends string | number | symbol>(source: T, propNames: readonly K[]): Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>;
10
- export declare function isEmptyObject(params: Record<string, unknown>): boolean;
11
- type KeysMatching<T, V> = {
12
- [K in keyof T]: T[K] extends V ? K : never;
13
- }[keyof T];
14
- /**
15
- * @param array The array of objects to be grouped.
16
- * @param selector The key used for grouping the objects.
17
- * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.
18
- */
19
- export declare function groupBy<T extends object, K extends KeysMatching<T, RecordKeyType | null | undefined>>(array: T[], selector: K): Record<RecordKeyType, T[]>;
20
- /**
21
- * @param array The array of objects to be grouped.
22
- * @param selector The key used for grouping the objects. Support nested keys.
23
- * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.
24
- */
25
- export declare function groupByPath<T extends object>(array: T[], selector: string): Record<string, T[]>;
26
- /**
27
- * @param array The array of objects to be grouped.
28
- * @param selector The key used for grouping the objects.
29
- * @returns An object where the keys are unique values from the given selector and the value is the
30
- * corresponding object from the array.
31
- * @throws InternalError If a duplicated value is found for the given selector.
32
- */
33
- export declare function groupByUnique<T extends object, K extends KeysMatching<T, RecordKeyType | null | undefined>>(array: T[], selector: K): Record<RecordKeyType, T>;
34
- type DatesAsString<T> = T extends Date ? string : ExactlyLikeWithDateAsString<T>;
35
- type ExactlyLikeWithDateAsString<T> = T extends object ? {
36
- [K in keyof T]: DatesAsString<T[K]>;
37
- } : T;
38
- export declare function convertDateFieldsToIsoString<Input extends object>(object: Input): ExactlyLikeWithDateAsString<Input>;
39
- export declare function convertDateFieldsToIsoString<Input extends object>(object: Input[]): ExactlyLikeWithDateAsString<Input>[];
40
- /**
41
- * Return a deep clone copy of an object.
42
- *
43
- * Please Note: This uses structuredClone, which has the limitations of these restricted Types: functions,
44
- * Error objects, WeakMap, WeakSet, DOM nodes, and certain other browser-specific objects like Window.
45
- */
46
- export declare function deepClone<T extends object | undefined | null>(object: T): T;
47
- type TransformToKebabCaseInputType = Record<string, unknown> | null | undefined;
48
- type TransformToKebabCaseReturnType<Input, Output> = Input extends Record<string, unknown> ? Output : Input;
49
- /**
50
- * Transforms an object's keys from camelCase or snake_case to kebab-case.
51
- * @param object
52
- */
53
- export declare function transformToKebabCase<Output extends Record<string, unknown>, Input extends TransformToKebabCaseInputType>(object: Input): TransformToKebabCaseReturnType<Input, Output>;
54
- export declare function transformToKebabCase<Output extends Record<string, unknown>, Input extends TransformToKebabCaseInputType>(object: Input[]): TransformToKebabCaseReturnType<Input, Output>[];
55
- export {};
@@ -1,195 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.copyWithoutUndefined = copyWithoutUndefined;
4
- exports.copyWithoutEmpty = copyWithoutEmpty;
5
- exports.pick = pick;
6
- exports.pickWithoutUndefined = pickWithoutUndefined;
7
- exports.isEmptyObject = isEmptyObject;
8
- exports.groupBy = groupBy;
9
- exports.groupByPath = groupByPath;
10
- exports.groupByUnique = groupByUnique;
11
- exports.convertDateFieldsToIsoString = convertDateFieldsToIsoString;
12
- exports.deepClone = deepClone;
13
- exports.transformToKebabCase = transformToKebabCase;
14
- const tslib_1 = require("tslib");
15
- const dot_prop_1 = tslib_1.__importDefault(require("dot-prop"));
16
- const InternalError_1 = require("../errors/InternalError");
17
- function copyWithoutUndefined(originalValue) {
18
- return Object.keys(originalValue).reduce((acc, key) => {
19
- // @ts-ignore
20
- if (originalValue[key] !== undefined) {
21
- // @ts-ignore
22
- acc[key] = originalValue[key];
23
- }
24
- return acc;
25
- }, {});
26
- }
27
- function copyWithoutEmpty(originalValue) {
28
- return Object.keys(originalValue).reduce((acc, key) => {
29
- if (originalValue[key] !== undefined &&
30
- originalValue[key] !== null &&
31
- // @ts-ignore
32
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
33
- (typeof originalValue[key] !== 'string' || originalValue[key].trim().length > 0)) {
34
- // @ts-ignore
35
- acc[key] = originalValue[key];
36
- }
37
- return acc;
38
- }, {});
39
- }
40
- function pick(source, propNames) {
41
- const result = {};
42
- let idx = 0;
43
- while (idx < propNames.length) {
44
- // @ts-ignore
45
- if (propNames[idx] in source) {
46
- // @ts-ignore
47
- result[propNames[idx]] = source[propNames[idx]];
48
- }
49
- idx += 1;
50
- }
51
- return result;
52
- }
53
- function pickWithoutUndefined(source, propNames) {
54
- const result = {};
55
- let idx = 0;
56
- while (idx < propNames.length) {
57
- // @ts-ignore
58
- if (propNames[idx] in source && source[propNames[idx]] !== undefined) {
59
- // @ts-ignore
60
- result[propNames[idx]] = source[propNames[idx]];
61
- }
62
- idx += 1;
63
- }
64
- return result;
65
- }
66
- function isEmptyObject(params) {
67
- for (const key in params) {
68
- if (Object.hasOwn(params, key) && params[key] !== undefined) {
69
- return false;
70
- }
71
- }
72
- return true;
73
- }
74
- /**
75
- * @param array The array of objects to be grouped.
76
- * @param selector The key used for grouping the objects.
77
- * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.
78
- */
79
- function groupBy(array, selector) {
80
- return array.reduce((acc, item) => {
81
- const key = item[selector];
82
- if (key === undefined || key === null) {
83
- return acc;
84
- }
85
- if (!acc[key]) {
86
- acc[key] = [];
87
- }
88
- acc[key].push(item);
89
- return acc;
90
- }, {});
91
- }
92
- /**
93
- * @param array The array of objects to be grouped.
94
- * @param selector The key used for grouping the objects. Support nested keys.
95
- * @returns An object where the keys are unique values from the given selector and the values are the corresponding objects from the array.
96
- */
97
- function groupByPath(array, selector) {
98
- return array.reduce((acc, item) => {
99
- const key = dot_prop_1.default.get(item, selector);
100
- if (key === undefined || key === null) {
101
- return acc;
102
- }
103
- const strKeyPath = key;
104
- if (!acc[strKeyPath]) {
105
- acc[strKeyPath] = [];
106
- }
107
- acc[strKeyPath].push(item);
108
- return acc;
109
- }, {});
110
- }
111
- /**
112
- * @param array The array of objects to be grouped.
113
- * @param selector The key used for grouping the objects.
114
- * @returns An object where the keys are unique values from the given selector and the value is the
115
- * corresponding object from the array.
116
- * @throws InternalError If a duplicated value is found for the given selector.
117
- */
118
- function groupByUnique(array, selector) {
119
- return array.reduce((acc, item) => {
120
- const key = item[selector];
121
- if (key === undefined || key === null) {
122
- return acc;
123
- }
124
- if (acc[key] !== undefined) {
125
- throw new InternalError_1.InternalError({
126
- message: `Duplicated item for selector ${selector.toString()} with value ${key.toString()}`,
127
- errorCode: 'DUPLICATED_ITEM',
128
- details: { selector, value: key },
129
- });
130
- }
131
- acc[key] = item;
132
- return acc;
133
- }, {});
134
- }
135
- function convertDateFieldsToIsoString(object) {
136
- if (Array.isArray(object)) {
137
- // @ts-ignore
138
- return object.map(convertDateFieldsToIsoStringAux);
139
- }
140
- return Object.entries(object).reduce((result, [key, value]) => {
141
- // @ts-ignore
142
- result[key] = convertDateFieldsToIsoStringAux(value);
143
- return result;
144
- }, {});
145
- }
146
- function convertDateFieldsToIsoStringAux(item) {
147
- if (item instanceof Date) {
148
- // @ts-ignore
149
- return item.toISOString();
150
- }
151
- if (item && typeof item === 'object') {
152
- // @ts-ignore
153
- return convertDateFieldsToIsoString(item);
154
- }
155
- // @ts-ignore
156
- return item;
157
- }
158
- /**
159
- * Return a deep clone copy of an object.
160
- *
161
- * Please Note: This uses structuredClone, which has the limitations of these restricted Types: functions,
162
- * Error objects, WeakMap, WeakSet, DOM nodes, and certain other browser-specific objects like Window.
163
- */
164
- function deepClone(object) {
165
- if (object === undefined || object === null) {
166
- return object;
167
- }
168
- return structuredClone(object);
169
- }
170
- function transformKey(key) {
171
- return key
172
- .replace(/([a-z])([A-Z])/g, '$1-$2') // transforms basic camelCase
173
- .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2') // transforms abbreviations
174
- .replace(/_/g, '-') // transforms snake_case
175
- .toLowerCase(); // finally lowercase all
176
- }
177
- function transformToKebabCase(object) {
178
- if (Array.isArray(object)) {
179
- // @ts-ignore
180
- return object.map(transformToKebabCase);
181
- }
182
- if (typeof object !== 'object' || object === null || object === undefined) {
183
- return object;
184
- }
185
- return Object.entries(object).reduce((result, [key, value]) => {
186
- const transformedKey = transformKey(key);
187
- const transformedValue = value && typeof value === 'object'
188
- ? transformToKebabCase(value)
189
- : value;
190
- // Avoiding destructuring by directly assigning the new key-value pair
191
- result[transformedKey] = transformedValue;
192
- return result;
193
- }, {});
194
- }
195
- //# sourceMappingURL=objectUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"objectUtils.js","sourceRoot":"","sources":["../../../src/utils/objectUtils.ts"],"names":[],"mappings":";;AAMA,oDAoBC;AAED,4CAyBC;AAED,oBAeC;AAED,oDAeC;AAED,sCAOC;AASD,0BAkBC;AAOD,kCAiBC;AASD,sCAsBC;AAYD,oEAgBC;AAuBD,8BAKC;AA4BD,oDAyBC;;AA/RD,gEAA8B;AAE9B,2DAAuD;AAIvD,SAAgB,oBAAoB,CAQlC,aAAgB;IAChB,OAAO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,CACtC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACX,aAAa;QACb,IAAI,aAAa,CAAC,GAAG,CA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CAAC,CAAC,2BAA2B;SACpE,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,wBAAwB;SAC3C,WAAW,EAAE,CAAA,CAAC,wBAAwB;AAC3C,CAAC;AAoBD,SAAgB,oBAAoB,CAClC,MAAuB;IAEvB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,aAAa;QACb,OAAO,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACzC,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC1E,OAAO,MAAuD,CAAA;IAChE,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,MAAiC,CAAC,CAAC,MAAM,CAC7D,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QACvB,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;QACxC,MAAM,gBAAgB,GACpB,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;YAChC,CAAC,CAAC,oBAAoB,CAAC,KAAsC,CAAC;YAC9D,CAAC,CAAC,KAAK,CAAA;QAEX,sEAAsE;QACtE,MAAM,CAAC,cAAc,CAAC,GAAG,gBAAgB,CAAA;QACzC,OAAO,MAAM,CAAA;IACf,CAAC,EACD,EAA6B,CACmB,CAAA;AACpD,CAAC"}
@@ -1,37 +0,0 @@
1
- import type { Readable } from 'node:stream';
2
- export type ReadableProvider = {
3
- /**
4
- * Guarantees to provide a new stream every time this is called, before `destroy` is invoked.
5
- */
6
- createStream(): Promise<Readable>;
7
- /**
8
- * Returns size of the persisted content
9
- */
10
- getContentLength(): Promise<number>;
11
- /**
12
- * Remove the persisted value. No new streams can be created after this is called
13
- */
14
- destroy(): Promise<void>;
15
- };
16
- export type PersistToFsOptions = {
17
- targetFile: string;
18
- sourceReadable: Readable;
19
- };
20
- export type FsReadableProviderOptions = {
21
- storageFile: string;
22
- };
23
- export declare class FsReadableProvider implements ReadableProvider {
24
- readonly storageFile: string;
25
- constructor(options: FsReadableProviderOptions);
26
- fileExists(): Promise<boolean>;
27
- getContentLength(): Promise<number>;
28
- createStream(): Promise<Readable>;
29
- destroy(): Promise<void>;
30
- protected persist(sourceReadable: Readable): Promise<void>;
31
- static persistReadableToFs(options: PersistToFsOptions): Promise<FsReadableProvider>;
32
- }
33
- /**
34
- * Consumes the readable in order to calculate its length in bytes
35
- * @param readable
36
- */
37
- export declare function getReadableContentLength(readable: Readable): Promise<number>;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FsReadableProvider = void 0;
4
- exports.getReadableContentLength = getReadableContentLength;
5
- const node_constants_1 = require("node:constants");
6
- const node_fs_1 = require("node:fs");
7
- const promises_1 = require("node:fs/promises");
8
- const node_stream_1 = require("node:stream");
9
- class FsReadableProvider {
10
- storageFile;
11
- constructor(options) {
12
- this.storageFile = options.storageFile;
13
- }
14
- fileExists() {
15
- return new Promise((resolve) => {
16
- (0, node_fs_1.access)(this.storageFile, node_constants_1.F_OK, (err) => {
17
- return resolve(!err);
18
- });
19
- });
20
- }
21
- async getContentLength() {
22
- if (!(await this.fileExists())) {
23
- throw new Error(`File ${this.storageFile} was already deleted.`);
24
- }
25
- const stats = await (0, promises_1.stat)(this.storageFile);
26
- return stats.size;
27
- }
28
- async createStream() {
29
- if (!(await this.fileExists())) {
30
- throw new Error(`File ${this.storageFile} was already deleted.`);
31
- }
32
- return (0, node_fs_1.createReadStream)(this.storageFile);
33
- }
34
- async destroy() {
35
- if (!(await this.fileExists())) {
36
- // nothing to do here
37
- return;
38
- }
39
- return (0, promises_1.unlink)(this.storageFile);
40
- }
41
- async persist(sourceReadable) {
42
- const writable = (0, node_fs_1.createWriteStream)(this.storageFile);
43
- return new Promise((resolve, reject) => {
44
- (0, node_stream_1.pipeline)(sourceReadable, writable, (err) => {
45
- if (err) {
46
- /* c8 ignore next 1 */
47
- reject(err);
48
- }
49
- else {
50
- resolve();
51
- }
52
- });
53
- });
54
- }
55
- static async persistReadableToFs(options) {
56
- const provider = new FsReadableProvider({
57
- storageFile: options.targetFile,
58
- });
59
- await provider.persist(options.sourceReadable);
60
- return provider;
61
- }
62
- }
63
- exports.FsReadableProvider = FsReadableProvider;
64
- /**
65
- * Consumes the readable in order to calculate its length in bytes
66
- * @param readable
67
- */
68
- function getReadableContentLength(readable) {
69
- return new Promise((resolve, reject) => {
70
- let size = 0;
71
- readable.on('data', (chunk) => {
72
- if (typeof chunk === 'string' || Buffer.isBuffer(chunk)) {
73
- size += Buffer.byteLength(chunk);
74
- }
75
- });
76
- readable.on('end', () => {
77
- resolve(size);
78
- });
79
- readable.on('error', (error) => {
80
- /* c8 ignore next 1 */
81
- reject(error);
82
- });
83
- });
84
- }
85
- //# sourceMappingURL=streamUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"streamUtils.js","sourceRoot":"","sources":["../../../src/utils/streamUtils.ts"],"names":[],"mappings":";;;AAoGA,4DAgBC;AApHD,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,EAAC,IAAI,CAAC,WAAW,EAAE,qBAAI,EAAE,CAAC,GAAG,EAAE,EAAE;gBACrC,OAAO,OAAO,CAAC,CAAC,GAAG,CAAC,CAAA;YACtB,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC;YAC/B,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C,WAAW,EAAE,OAAO,CAAC,UAAU;SAChC,CAAC,CAAA;QACF,MAAM,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;QAC9C,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF;AA9DD,gDA8DC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,QAAkB;IACzD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,IAAI,GAAG,CAAC,CAAA;QACZ,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;YAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxD,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;YAClC,CAAC;QACH,CAAC,CAAC,CAAA;QACF,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACtB,OAAO,CAAC,IAAI,CAAC,CAAA;QACf,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"}
@@ -1,10 +0,0 @@
1
- export type StandardizedError = {
2
- code: string;
3
- message: string;
4
- };
5
- export declare function hasMessage(maybe: unknown): maybe is {
6
- message: string;
7
- };
8
- export declare function isObject(maybeObject: unknown): maybeObject is Record<PropertyKey, unknown>;
9
- export declare function isStandardizedError(error: unknown): error is StandardizedError;
10
- export declare function isError(maybeError: unknown): maybeError is Error;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasMessage = hasMessage;
4
- exports.isObject = isObject;
5
- exports.isStandardizedError = isStandardizedError;
6
- exports.isError = isError;
7
- function hasMessage(maybe) {
8
- return isObject(maybe) && typeof maybe.message === 'string';
9
- }
10
- function isObject(maybeObject) {
11
- return typeof maybeObject === 'object' && maybeObject !== null;
12
- }
13
- function isStandardizedError(error) {
14
- return isObject(error) && typeof error.code === 'string' && typeof error.message === 'string';
15
- }
16
- function isError(maybeError) {
17
- return (maybeError instanceof Error || Object.prototype.toString.call(maybeError) === '[object Error]');
18
- }
19
- //# sourceMappingURL=typeUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"typeUtils.js","sourceRoot":"","sources":["../../../src/utils/typeUtils.ts"],"names":[],"mappings":";;AAMA,gCAEC;AAED,4BAEC;AAED,kDAEC;AAED,0BAIC;AAhBD,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAA;AAC7D,CAAC;AAED,SAAgB,QAAQ,CAAC,WAAoB;IAC3C,OAAO,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,KAAK,IAAI,CAAA;AAChE,CAAC;AAED,SAAgB,mBAAmB,CAAC,KAAc;IAChD,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAA;AAC/F,CAAC;AAED,SAAgB,OAAO,CAAC,UAAmB;IACzC,OAAO,CACL,UAAU,YAAY,KAAK,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,gBAAgB,CAC/F,CAAA;AACH,CAAC"}
@@ -1 +0,0 @@
1
- export declare const waitAndRetry: <T>(predicateFn: () => T, sleepTime?: number, maxRetryCount?: number) => Promise<T>;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.waitAndRetry = void 0;
4
- const waitAndRetry = async (predicateFn, sleepTime = 20, maxRetryCount = 15) => {
5
- return new Promise((resolve, reject) => {
6
- let retryCount = 0;
7
- function performCheck() {
8
- // amount of retries exceeded
9
- if (maxRetryCount !== 0 && retryCount > maxRetryCount) {
10
- resolve(predicateFn());
11
- }
12
- // Try executing predicateFn
13
- Promise.resolve()
14
- .then(() => {
15
- return predicateFn();
16
- })
17
- .then((result) => {
18
- if (result) {
19
- resolve(result);
20
- }
21
- else {
22
- retryCount++;
23
- setTimeout(performCheck, sleepTime);
24
- }
25
- })
26
- .catch((err) => {
27
- reject(err);
28
- });
29
- }
30
- performCheck();
31
- });
32
- };
33
- exports.waitAndRetry = waitAndRetry;
34
- //# sourceMappingURL=waitUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"waitUtils.js","sourceRoot":"","sources":["../../../src/utils/waitUtils.ts"],"names":[],"mappings":";;;AAAO,MAAM,YAAY,GAAG,KAAK,EAC/B,WAAoB,EACpB,SAAS,GAAG,EAAE,EACd,aAAa,GAAG,EAAE,EACN,EAAE;IACd,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,UAAU,GAAG,CAAC,CAAA;QAClB,SAAS,YAAY;YACnB,6BAA6B;YAC7B,IAAI,aAAa,KAAK,CAAC,IAAI,UAAU,GAAG,aAAa,EAAE,CAAC;gBACtD,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;YACxB,CAAC;YAED,4BAA4B;YAC5B,OAAO,CAAC,OAAO,EAAE;iBACd,IAAI,CAAC,GAAG,EAAE;gBACT,OAAO,WAAW,EAAE,CAAA;YACtB,CAAC,CAAC;iBACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;gBACf,IAAI,MAAM,EAAE,CAAC;oBACX,OAAO,CAAC,MAAM,CAAC,CAAA;gBACjB,CAAC;qBAAM,CAAC;oBACN,UAAU,EAAE,CAAA;oBACZ,UAAU,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;gBACrC,CAAC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,MAAM,CAAC,GAAG,CAAC,CAAA;YACb,CAAC,CAAC,CAAA;QACN,CAAC;QAED,YAAY,EAAE,CAAA;IAChB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAjCY,QAAA,YAAY,gBAiCxB"}