@naturalcycles/nodejs-lib 13.45.4 → 14.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 (197) hide show
  1. package/dist/bin/generate-build-info.js +15 -18
  2. package/dist/bin/json2env.js +6 -9
  3. package/dist/bin/kpy.js +6 -9
  4. package/dist/bin/secrets-decrypt.d.ts +1 -1
  5. package/dist/bin/secrets-decrypt.js +9 -12
  6. package/dist/bin/secrets-encrypt.d.ts +1 -1
  7. package/dist/bin/secrets-encrypt.js +9 -12
  8. package/dist/bin/secrets-gen-key.js +8 -11
  9. package/dist/bin/slack-this.js +6 -9
  10. package/dist/buffer/buffer.util.js +1 -4
  11. package/dist/colors/colors.d.ts +26 -27
  12. package/dist/colors/colors.js +29 -33
  13. package/dist/csv/csvReader.js +4 -8
  14. package/dist/csv/csvWriter.js +6 -12
  15. package/dist/csv/transformToCSV.d.ts +2 -2
  16. package/dist/csv/transformToCSV.js +5 -8
  17. package/dist/diff/tableDiff.js +4 -7
  18. package/dist/fs/fs2.d.ts +1 -1
  19. package/dist/fs/fs2.js +82 -86
  20. package/dist/fs/json2env.js +18 -28
  21. package/dist/fs/kpy.js +28 -33
  22. package/dist/index.d.ts +71 -71
  23. package/dist/index.js +73 -78
  24. package/dist/infra/process.util.js +22 -28
  25. package/dist/jwt/jwt.service.js +16 -21
  26. package/dist/log/log.util.js +4 -7
  27. package/dist/script/runScript.js +11 -15
  28. package/dist/secret/secrets-decrypt.util.js +18 -22
  29. package/dist/secret/secrets-encrypt.util.js +17 -21
  30. package/dist/security/crypto.util.js +24 -34
  31. package/dist/security/hash.util.js +19 -37
  32. package/dist/security/id.util.js +11 -18
  33. package/dist/security/nanoid.js +15 -20
  34. package/dist/security/secret.util.js +20 -30
  35. package/dist/slack/slack.service.d.ts +1 -1
  36. package/dist/slack/slack.service.js +11 -16
  37. package/dist/slack/slack.service.model.d.ts +1 -1
  38. package/dist/slack/slack.service.model.js +1 -2
  39. package/dist/stream/ndjson/ndjson.model.js +7 -11
  40. package/dist/stream/ndjson/ndjsonMap.d.ts +1 -1
  41. package/dist/stream/ndjson/ndjsonMap.js +11 -14
  42. package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +1 -1
  43. package/dist/stream/ndjson/ndjsonStreamForEach.js +9 -12
  44. package/dist/stream/ndjson/transformJsonParse.d.ts +1 -1
  45. package/dist/stream/ndjson/transformJsonParse.js +4 -9
  46. package/dist/stream/ndjson/transformToNDJson.d.ts +1 -1
  47. package/dist/stream/ndjson/transformToNDJson.js +5 -8
  48. package/dist/stream/pipeline/pipeline.js +11 -17
  49. package/dist/stream/progressLogger.d.ts +1 -1
  50. package/dist/stream/progressLogger.js +22 -28
  51. package/dist/stream/readable/readableCreate.d.ts +1 -1
  52. package/dist/stream/readable/readableCreate.js +5 -9
  53. package/dist/stream/readable/readableForEach.d.ts +2 -2
  54. package/dist/stream/readable/readableForEach.js +7 -11
  55. package/dist/stream/readable/readableFromArray.d.ts +1 -1
  56. package/dist/stream/readable/readableFromArray.js +4 -7
  57. package/dist/stream/readable/readableToArray.d.ts +1 -1
  58. package/dist/stream/readable/readableToArray.js +1 -4
  59. package/dist/stream/sizeStack.js +7 -11
  60. package/dist/stream/stream.model.js +1 -2
  61. package/dist/stream/stream.util.js +1 -4
  62. package/dist/stream/transform/transformChunk.d.ts +1 -1
  63. package/dist/stream/transform/transformChunk.js +3 -6
  64. package/dist/stream/transform/transformFilter.d.ts +2 -2
  65. package/dist/stream/transform/transformFilter.js +6 -10
  66. package/dist/stream/transform/transformLimit.d.ts +2 -2
  67. package/dist/stream/transform/transformLimit.js +6 -11
  68. package/dist/stream/transform/transformLogProgress.d.ts +2 -2
  69. package/dist/stream/transform/transformLogProgress.js +5 -8
  70. package/dist/stream/transform/transformMap.d.ts +1 -1
  71. package/dist/stream/transform/transformMap.js +18 -22
  72. package/dist/stream/transform/transformMapSimple.d.ts +1 -1
  73. package/dist/stream/transform/transformMapSimple.js +6 -9
  74. package/dist/stream/transform/transformMapSync.d.ts +3 -3
  75. package/dist/stream/transform/transformMapSync.js +14 -19
  76. package/dist/stream/transform/transformNoOp.d.ts +1 -1
  77. package/dist/stream/transform/transformNoOp.js +3 -6
  78. package/dist/stream/transform/transformOffset.d.ts +1 -1
  79. package/dist/stream/transform/transformOffset.js +5 -8
  80. package/dist/stream/transform/transformSplit.d.ts +1 -1
  81. package/dist/stream/transform/transformSplit.js +5 -9
  82. package/dist/stream/transform/transformTap.d.ts +1 -1
  83. package/dist/stream/transform/transformTap.js +3 -6
  84. package/dist/stream/transform/transformTee.d.ts +1 -1
  85. package/dist/stream/transform/transformTee.js +7 -10
  86. package/dist/stream/transform/transformThrottle.d.ts +1 -1
  87. package/dist/stream/transform/transformThrottle.js +9 -12
  88. package/dist/stream/transform/transformToArray.d.ts +1 -1
  89. package/dist/stream/transform/transformToArray.js +3 -6
  90. package/dist/stream/transform/worker/baseWorkerClass.d.ts +1 -1
  91. package/dist/stream/transform/worker/baseWorkerClass.js +1 -5
  92. package/dist/stream/transform/worker/transformMultiThreaded.d.ts +1 -1
  93. package/dist/stream/transform/worker/transformMultiThreaded.js +12 -11
  94. package/dist/stream/transform/worker/transformMultiThreaded.model.js +1 -2
  95. package/dist/stream/transform/worker/workerClassProxy.js +6 -4
  96. package/dist/stream/writable/writableForEach.d.ts +2 -2
  97. package/dist/stream/writable/writableForEach.js +6 -10
  98. package/dist/stream/writable/writableFork.d.ts +1 -1
  99. package/dist/stream/writable/writableFork.js +6 -9
  100. package/dist/stream/writable/writableLimit.d.ts +1 -1
  101. package/dist/stream/writable/writableLimit.js +3 -6
  102. package/dist/stream/writable/writablePushToArray.d.ts +1 -1
  103. package/dist/stream/writable/writablePushToArray.js +3 -6
  104. package/dist/stream/writable/writableVoid.d.ts +1 -1
  105. package/dist/stream/writable/writableVoid.js +3 -6
  106. package/dist/string/inspect.js +8 -13
  107. package/dist/util/buildInfo.util.js +12 -15
  108. package/dist/util/env.util.js +5 -9
  109. package/dist/util/exec2.js +17 -21
  110. package/dist/util/git2.js +17 -20
  111. package/dist/util/lruMemoCache.js +3 -7
  112. package/dist/util/zip.util.js +14 -25
  113. package/dist/validation/ajv/ajv.util.d.ts +3 -3
  114. package/dist/validation/ajv/ajv.util.js +6 -10
  115. package/dist/validation/ajv/ajvSchema.d.ts +2 -2
  116. package/dist/validation/ajv/ajvSchema.js +14 -18
  117. package/dist/validation/ajv/ajvValidationError.js +2 -6
  118. package/dist/validation/ajv/getAjv.d.ts +1 -1
  119. package/dist/validation/ajv/getAjv.js +9 -9
  120. package/dist/validation/joi/joi.extensions.d.ts +2 -2
  121. package/dist/validation/joi/joi.extensions.js +6 -10
  122. package/dist/validation/joi/joi.model.js +1 -2
  123. package/dist/validation/joi/joi.shared.schemas.d.ts +2 -2
  124. package/dist/validation/joi/joi.shared.schemas.js +61 -74
  125. package/dist/validation/joi/joi.validation.error.js +2 -6
  126. package/dist/validation/joi/joi.validation.util.d.ts +1 -1
  127. package/dist/validation/joi/joi.validation.util.js +10 -17
  128. package/dist/validation/joi/number.extensions.js +1 -4
  129. package/dist/validation/joi/string.extensions.js +4 -7
  130. package/dist/yargs.util.js +5 -8
  131. package/package.json +5 -4
  132. package/src/bin/generate-build-info.ts +3 -3
  133. package/src/bin/json2env.ts +2 -2
  134. package/src/bin/kpy.ts +2 -2
  135. package/src/bin/secrets-decrypt.ts +7 -8
  136. package/src/bin/secrets-encrypt.ts +7 -8
  137. package/src/bin/secrets-gen-key.ts +2 -2
  138. package/src/bin/slack-this.ts +2 -2
  139. package/src/csv/transformToCSV.ts +3 -3
  140. package/src/fs/fs2.ts +4 -4
  141. package/src/fs/json2env.ts +2 -2
  142. package/src/fs/kpy.ts +2 -2
  143. package/src/index.ts +71 -71
  144. package/src/jwt/jwt.service.ts +2 -2
  145. package/src/log/log.util.ts +1 -1
  146. package/src/script/runScript.ts +4 -3
  147. package/src/secret/secrets-decrypt.util.ts +3 -3
  148. package/src/secret/secrets-encrypt.util.ts +3 -3
  149. package/src/security/crypto.util.ts +1 -1
  150. package/src/security/id.util.ts +1 -1
  151. package/src/security/secret.util.ts +2 -2
  152. package/src/slack/slack.service.model.ts +1 -1
  153. package/src/slack/slack.service.ts +3 -3
  154. package/src/stream/ndjson/ndjson.model.ts +1 -1
  155. package/src/stream/ndjson/ndjsonMap.ts +2 -2
  156. package/src/stream/ndjson/ndjsonStreamForEach.ts +2 -2
  157. package/src/stream/ndjson/transformJsonParse.ts +1 -1
  158. package/src/stream/ndjson/transformToNDJson.ts +1 -1
  159. package/src/stream/pipeline/pipeline.ts +1 -1
  160. package/src/stream/progressLogger.ts +3 -3
  161. package/src/stream/readable/readableCreate.ts +1 -1
  162. package/src/stream/readable/readableForEach.ts +4 -4
  163. package/src/stream/readable/readableFromArray.ts +1 -1
  164. package/src/stream/readable/readableToArray.ts +1 -1
  165. package/src/stream/sizeStack.ts +2 -2
  166. package/src/stream/transform/transformChunk.ts +1 -1
  167. package/src/stream/transform/transformFilter.ts +3 -3
  168. package/src/stream/transform/transformLimit.ts +3 -3
  169. package/src/stream/transform/transformLogProgress.ts +3 -3
  170. package/src/stream/transform/transformMap.ts +5 -5
  171. package/src/stream/transform/transformMapSimple.ts +1 -1
  172. package/src/stream/transform/transformMapSync.ts +5 -5
  173. package/src/stream/transform/transformNoOp.ts +1 -1
  174. package/src/stream/transform/transformOffset.ts +2 -2
  175. package/src/stream/transform/transformSplit.ts +1 -1
  176. package/src/stream/transform/transformTap.ts +1 -1
  177. package/src/stream/transform/transformTee.ts +3 -3
  178. package/src/stream/transform/transformThrottle.ts +1 -1
  179. package/src/stream/transform/transformToArray.ts +1 -1
  180. package/src/stream/transform/worker/baseWorkerClass.ts +1 -1
  181. package/src/stream/transform/worker/transformMultiThreaded.ts +8 -3
  182. package/src/stream/transform/worker/workerClassProxy.js +6 -4
  183. package/src/stream/writable/writableForEach.ts +3 -3
  184. package/src/stream/writable/writableFork.ts +3 -3
  185. package/src/stream/writable/writableLimit.ts +1 -1
  186. package/src/stream/writable/writablePushToArray.ts +1 -1
  187. package/src/stream/writable/writableVoid.ts +1 -1
  188. package/src/util/buildInfo.util.ts +2 -2
  189. package/src/util/exec2.ts +1 -1
  190. package/src/util/git2.ts +2 -2
  191. package/src/validation/ajv/ajv.util.ts +4 -4
  192. package/src/validation/ajv/ajvSchema.ts +4 -5
  193. package/src/validation/ajv/getAjv.ts +7 -3
  194. package/src/validation/joi/joi.extensions.ts +4 -4
  195. package/src/validation/joi/joi.shared.schemas.ts +3 -3
  196. package/src/validation/joi/joi.validation.util.ts +2 -2
  197. package/src/yargs.util.ts +1 -0
@@ -1,43 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.secretsEncrypt = secretsEncrypt;
4
- const tslib_1 = require("tslib");
5
- const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
7
- const js_lib_1 = require("@naturalcycles/js-lib");
8
- const colors_1 = require("../colors/colors");
9
- const index_1 = require("../index");
10
- const crypto_util_1 = require("../security/crypto.util");
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { _assert } from '@naturalcycles/js-lib';
4
+ import { dimGrey, yellow } from '../colors/colors.js';
5
+ import { fastGlob, fs2 } from '../index.js';
6
+ import { encryptObject, encryptRandomIVBuffer } from '../security/crypto.util.js';
11
7
  /**
12
8
  * Encrypts all files in given directory (except *.enc), saves encrypted versions as filename.ext.enc.
13
9
  * Using provided encKey.
14
10
  */
15
- function secretsEncrypt(pattern, file, encKeyBuffer, del = false, jsonMode = false) {
11
+ export function secretsEncrypt(pattern, file, encKeyBuffer, del = false, jsonMode = false) {
16
12
  const patterns = file
17
13
  ? [file]
18
14
  : [
19
15
  ...pattern,
20
16
  `!**/*.enc`, // excluding already encoded
21
17
  ];
22
- const filenames = index_1.fastGlob.sync(patterns);
18
+ const filenames = fastGlob.sync(patterns);
23
19
  let encFilename;
24
20
  filenames.forEach(filename => {
25
21
  if (jsonMode) {
26
- (0, js_lib_1._assert)(filename.endsWith('.plain.json'), `${node_path_1.default.basename(filename)} MUST end with '.plain.json'`);
22
+ _assert(filename.endsWith('.plain.json'), `${path.basename(filename)} MUST end with '.plain.json'`);
27
23
  encFilename = filename.replace('.plain', '');
28
- const json = (0, crypto_util_1.encryptObject)(index_1.fs2.readJson(filename), encKeyBuffer);
29
- index_1.fs2.writeJson(encFilename, json, { spaces: 2 });
24
+ const json = encryptObject(fs2.readJson(filename), encKeyBuffer);
25
+ fs2.writeJson(encFilename, json, { spaces: 2 });
30
26
  }
31
27
  else {
32
- const plain = node_fs_1.default.readFileSync(filename);
33
- const enc = (0, crypto_util_1.encryptRandomIVBuffer)(plain, encKeyBuffer);
28
+ const plain = fs.readFileSync(filename);
29
+ const enc = encryptRandomIVBuffer(plain, encKeyBuffer);
34
30
  encFilename = `${filename}.enc`;
35
- node_fs_1.default.writeFileSync(encFilename, enc);
31
+ fs.writeFileSync(encFilename, enc);
36
32
  }
37
33
  if (del) {
38
- node_fs_1.default.unlinkSync(filename);
34
+ fs.unlinkSync(filename);
39
35
  }
40
- console.log(` ${node_path_1.default.basename(filename)} > ${node_path_1.default.basename(encFilename)}`);
36
+ console.log(` ${path.basename(filename)} > ${path.basename(encFilename)}`);
41
37
  });
42
- console.log(`encrypted ${(0, colors_1.yellow)(filenames.length)} files in (${(0, colors_1.dimGrey)(pattern.join(' '))})`);
38
+ console.log(`encrypted ${yellow(filenames.length)} files in (${dimGrey(pattern.join(' '))})`);
43
39
  }
@@ -1,49 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encryptRandomIVBuffer = encryptRandomIVBuffer;
4
- exports.decryptRandomIVBuffer = decryptRandomIVBuffer;
5
- exports.decryptObject = decryptObject;
6
- exports.encryptObject = encryptObject;
7
- exports.decryptString = decryptString;
8
- exports.encryptString = encryptString;
9
- exports.timingSafeStringEqual = timingSafeStringEqual;
10
- const tslib_1 = require("tslib");
11
- const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
12
- const js_lib_1 = require("@naturalcycles/js-lib");
13
- const hash_util_1 = require("./hash.util");
1
+ import crypto from 'node:crypto';
2
+ import { _stringMapEntries } from '@naturalcycles/js-lib';
3
+ import { md5AsBuffer, sha256AsBuffer } from './hash.util.js';
14
4
  const algorithm = 'aes-256-cbc';
15
5
  /**
16
6
  * Using aes-256-cbc.
17
7
  */
18
- function encryptRandomIVBuffer(input, secretKeyBuffer) {
8
+ export function encryptRandomIVBuffer(input, secretKeyBuffer) {
19
9
  // sha256 to match aes-256 key length
20
- const key = (0, hash_util_1.sha256AsBuffer)(secretKeyBuffer);
10
+ const key = sha256AsBuffer(secretKeyBuffer);
21
11
  // Random iv to achieve non-deterministic encryption (but deterministic decryption)
22
- const iv = node_crypto_1.default.randomBytes(16);
23
- const cipher = node_crypto_1.default.createCipheriv(algorithm, key, iv);
12
+ const iv = crypto.randomBytes(16);
13
+ const cipher = crypto.createCipheriv(algorithm, key, iv);
24
14
  return Buffer.concat([iv, cipher.update(input), cipher.final()]);
25
15
  }
26
16
  /**
27
17
  * Using aes-256-cbc.
28
18
  */
29
- function decryptRandomIVBuffer(input, secretKeyBuffer) {
19
+ export function decryptRandomIVBuffer(input, secretKeyBuffer) {
30
20
  // sha256 to match aes-256 key length
31
- const key = (0, hash_util_1.sha256AsBuffer)(secretKeyBuffer);
21
+ const key = sha256AsBuffer(secretKeyBuffer);
32
22
  // iv is first 16 bytes of encrypted buffer, the rest is payload
33
23
  const iv = input.subarray(0, 16);
34
24
  const payload = input.subarray(16);
35
- const decipher = node_crypto_1.default.createDecipheriv(algorithm, key, iv);
25
+ const decipher = crypto.createDecipheriv(algorithm, key, iv);
36
26
  return Buffer.concat([decipher.update(payload), decipher.final()]);
37
27
  }
38
28
  /**
39
29
  * Decrypts all object values (base64 strings).
40
30
  * Returns object with decrypted values (utf8 strings).
41
31
  */
42
- function decryptObject(obj, secretKeyBuffer) {
32
+ export function decryptObject(obj, secretKeyBuffer) {
43
33
  const { key, iv } = getCryptoParams(secretKeyBuffer);
44
34
  const r = {};
45
- (0, js_lib_1._stringMapEntries)(obj).forEach(([k, v]) => {
46
- const decipher = node_crypto_1.default.createDecipheriv(algorithm, key, iv);
35
+ _stringMapEntries(obj).forEach(([k, v]) => {
36
+ const decipher = crypto.createDecipheriv(algorithm, key, iv);
47
37
  r[k] = decipher.update(v, 'base64', 'utf8') + decipher.final('utf8');
48
38
  });
49
39
  return r;
@@ -52,11 +42,11 @@ function decryptObject(obj, secretKeyBuffer) {
52
42
  * Encrypts all object values (utf8 strings).
53
43
  * Returns object with encrypted values (base64 strings).
54
44
  */
55
- function encryptObject(obj, secretKeyBuffer) {
45
+ export function encryptObject(obj, secretKeyBuffer) {
56
46
  const { key, iv } = getCryptoParams(secretKeyBuffer);
57
47
  const r = {};
58
- (0, js_lib_1._stringMapEntries)(obj).forEach(([k, v]) => {
59
- const cipher = node_crypto_1.default.createCipheriv(algorithm, key, iv);
48
+ _stringMapEntries(obj).forEach(([k, v]) => {
49
+ const cipher = crypto.createCipheriv(algorithm, key, iv);
60
50
  r[k] = cipher.update(v, 'utf8', 'base64') + cipher.final('base64');
61
51
  });
62
52
  return r;
@@ -67,9 +57,9 @@ function encryptObject(obj, secretKeyBuffer) {
67
57
  * Input is base64 string.
68
58
  * Output is utf8 string.
69
59
  */
70
- function decryptString(str, secretKeyBuffer) {
60
+ export function decryptString(str, secretKeyBuffer) {
71
61
  const { key, iv } = getCryptoParams(secretKeyBuffer);
72
- const decipher = node_crypto_1.default.createDecipheriv(algorithm, key, iv);
62
+ const decipher = crypto.createDecipheriv(algorithm, key, iv);
73
63
  return decipher.update(str, 'base64', 'utf8') + decipher.final('utf8');
74
64
  }
75
65
  /**
@@ -78,14 +68,14 @@ function decryptString(str, secretKeyBuffer) {
78
68
  * Input is utf8 string.
79
69
  * Output is base64 string.
80
70
  */
81
- function encryptString(str, secretKeyBuffer) {
71
+ export function encryptString(str, secretKeyBuffer) {
82
72
  const { key, iv } = getCryptoParams(secretKeyBuffer);
83
- const cipher = node_crypto_1.default.createCipheriv(algorithm, key, iv);
73
+ const cipher = crypto.createCipheriv(algorithm, key, iv);
84
74
  return cipher.update(str, 'utf8', 'base64') + cipher.final('base64');
85
75
  }
86
76
  function getCryptoParams(secretKeyBuffer) {
87
- const key = (0, hash_util_1.sha256AsBuffer)(secretKeyBuffer);
88
- const iv = (0, hash_util_1.md5AsBuffer)(Buffer.concat([secretKeyBuffer, key]));
77
+ const key = sha256AsBuffer(secretKeyBuffer);
78
+ const iv = md5AsBuffer(Buffer.concat([secretKeyBuffer, key]));
89
79
  return { key, iv };
90
80
  }
91
81
  /**
@@ -100,8 +90,8 @@ function getCryptoParams(secretKeyBuffer) {
100
90
  *
101
91
  * Returns true if inputs are equal, false otherwise.
102
92
  */
103
- function timingSafeStringEqual(s1, s2) {
93
+ export function timingSafeStringEqual(s1, s2) {
104
94
  if (s1 === undefined || s2 === undefined || s1.length !== s2.length)
105
95
  return false;
106
- return node_crypto_1.default.timingSafeEqual(Buffer.from(s1), Buffer.from(s2));
96
+ return crypto.timingSafeEqual(Buffer.from(s1), Buffer.from(s2));
107
97
  }
@@ -1,67 +1,49 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.md5 = md5;
4
- exports.md5AsBuffer = md5AsBuffer;
5
- exports.sha256 = sha256;
6
- exports.sha256AsBuffer = sha256AsBuffer;
7
- exports.hash = hash;
8
- exports.hashAsBuffer = hashAsBuffer;
9
- exports.base64 = base64;
10
- exports.base64Url = base64Url;
11
- exports.base64ToString = base64ToString;
12
- exports.base64UrlToString = base64UrlToString;
13
- exports.base64ToBuffer = base64ToBuffer;
14
- exports.base64UrlToBuffer = base64UrlToBuffer;
15
- exports.stringToBase64 = stringToBase64;
16
- exports.stringToBase64Url = stringToBase64Url;
17
- exports.bufferToBase64 = bufferToBase64;
18
- exports.bufferToBase64Url = bufferToBase64Url;
19
- const node_crypto_1 = require("node:crypto");
20
- function md5(s, outputEncoding = 'hex') {
1
+ import { hash as cryptoHash } from 'node:crypto';
2
+ export function md5(s, outputEncoding = 'hex') {
21
3
  return hash(s, 'md5', outputEncoding);
22
4
  }
23
- function md5AsBuffer(s) {
5
+ export function md5AsBuffer(s) {
24
6
  return hashAsBuffer(s, 'md5');
25
7
  }
26
- function sha256(s, outputEncoding = 'hex') {
8
+ export function sha256(s, outputEncoding = 'hex') {
27
9
  return hash(s, 'sha256', outputEncoding);
28
10
  }
29
- function sha256AsBuffer(s) {
11
+ export function sha256AsBuffer(s) {
30
12
  return hashAsBuffer(s, 'sha256');
31
13
  }
32
- function hash(s, algorithm, outputEncoding = 'hex') {
33
- return (0, node_crypto_1.hash)(algorithm, s, outputEncoding);
14
+ export function hash(s, algorithm, outputEncoding = 'hex') {
15
+ return cryptoHash(algorithm, s, outputEncoding);
34
16
  }
35
- function hashAsBuffer(s, algorithm) {
36
- return (0, node_crypto_1.hash)(algorithm, s, 'buffer');
17
+ export function hashAsBuffer(s, algorithm) {
18
+ return cryptoHash(algorithm, s, 'buffer');
37
19
  }
38
- function base64(s) {
20
+ export function base64(s) {
39
21
  return (typeof s === 'string' ? Buffer.from(s) : s).toString('base64');
40
22
  }
41
- function base64Url(s) {
23
+ export function base64Url(s) {
42
24
  return (typeof s === 'string' ? Buffer.from(s) : s).toString('base64url');
43
25
  }
44
- function base64ToString(strBase64) {
26
+ export function base64ToString(strBase64) {
45
27
  return Buffer.from(strBase64, 'base64').toString('utf8');
46
28
  }
47
- function base64UrlToString(strBase64Url) {
29
+ export function base64UrlToString(strBase64Url) {
48
30
  return Buffer.from(strBase64Url, 'base64url').toString('utf8');
49
31
  }
50
- function base64ToBuffer(strBase64) {
32
+ export function base64ToBuffer(strBase64) {
51
33
  return Buffer.from(strBase64, 'base64');
52
34
  }
53
- function base64UrlToBuffer(strBase64Url) {
35
+ export function base64UrlToBuffer(strBase64Url) {
54
36
  return Buffer.from(strBase64Url, 'base64url');
55
37
  }
56
- function stringToBase64(s) {
38
+ export function stringToBase64(s) {
57
39
  return Buffer.from(s, 'utf8').toString('base64');
58
40
  }
59
- function stringToBase64Url(s) {
41
+ export function stringToBase64Url(s) {
60
42
  return Buffer.from(s, 'utf8').toString('base64url');
61
43
  }
62
- function bufferToBase64(b) {
44
+ export function bufferToBase64(b) {
63
45
  return b.toString('base64');
64
46
  }
65
- function bufferToBase64Url(b) {
47
+ export function bufferToBase64Url(b) {
66
48
  return b.toString('base64url');
67
49
  }
@@ -1,25 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringIdBase62 = void 0;
4
- exports.stringId = stringId;
5
- exports.stringIdBase64 = stringIdBase64;
6
- exports.stringIdBase64Url = stringIdBase64Url;
7
- exports.stringIdNonAmbiguous = stringIdNonAmbiguous;
8
- const node_crypto_1 = require("node:crypto");
9
- const nanoid_1 = require("./nanoid");
1
+ import { randomBytes } from 'node:crypto';
2
+ import { ALPHABET_ALPHANUMERIC, ALPHABET_ALPHANUMERIC_LOWERCASE, ALPHABET_NONAMBIGUOUS, nanoIdCustomAlphabet, } from './nanoid.js';
10
3
  /**
11
4
  * Generate cryptographically-secure string id.
12
5
  * Powered by `nanoid`.
13
6
  */
14
- function stringId(length = 16, alphabet = nanoid_1.ALPHABET_ALPHANUMERIC_LOWERCASE) {
15
- return (0, nanoid_1.nanoIdCustomAlphabet)(alphabet, length)();
7
+ export function stringId(length = 16, alphabet = ALPHABET_ALPHANUMERIC_LOWERCASE) {
8
+ return nanoIdCustomAlphabet(alphabet, length)();
16
9
  }
17
10
  /**
18
11
  * Generate a string id of Base62 alphabet (same as "alphanumeric": A-Za-z0-9)
19
12
  *
20
13
  * Length is 16 (non-configurable currently).
21
14
  */
22
- exports.stringIdBase62 = (0, nanoid_1.nanoIdCustomAlphabet)(nanoid_1.ALPHABET_ALPHANUMERIC, 16);
15
+ export const stringIdBase62 = nanoIdCustomAlphabet(ALPHABET_ALPHANUMERIC, 16);
23
16
  /**
24
17
  * Generate a string id of Base64 alphabet: A-Za-z0-9+/
25
18
  *
@@ -28,8 +21,8 @@ exports.stringIdBase62 = (0, nanoid_1.nanoIdCustomAlphabet)(nanoid_1.ALPHABET_AL
28
21
  *
29
22
  * Dividable by 4 lengths produce ids with no padding `=` characters, which is optimal.
30
23
  */
31
- function stringIdBase64(size = 16) {
32
- return (0, node_crypto_1.randomBytes)(size * 0.75).toString('base64');
24
+ export function stringIdBase64(size = 16) {
25
+ return randomBytes(size * 0.75).toString('base64');
33
26
  }
34
27
  /**
35
28
  * Generate a string id of Base64url alphabet: A-Za-z0-9-_
@@ -39,8 +32,8 @@ function stringIdBase64(size = 16) {
39
32
  *
40
33
  * Base64url always produces strings without a padding character `=`, by design.
41
34
  */
42
- function stringIdBase64Url(size = 16) {
43
- return (0, node_crypto_1.randomBytes)(size * 0.75).toString('base64url');
35
+ export function stringIdBase64Url(size = 16) {
36
+ return randomBytes(size * 0.75).toString('base64url');
44
37
  }
45
38
  /**
46
39
  * Generate cryptographically-secure string id with non-ambiguous characters only,
@@ -48,6 +41,6 @@ function stringIdBase64Url(size = 16) {
48
41
  *
49
42
  * Default length is 16.
50
43
  */
51
- function stringIdNonAmbiguous(size = 16) {
52
- return stringId(size, nanoid_1.ALPHABET_NONAMBIGUOUS);
44
+ export function stringIdNonAmbiguous(size = 16) {
45
+ return stringId(size, ALPHABET_NONAMBIGUOUS);
53
46
  }
@@ -1,25 +1,20 @@
1
- "use strict";
2
1
  /*
3
2
 
4
3
  This file is "vendored" from Nanoid, all credit is to Nanoid authors:
5
4
  https://github.com/ai/nanoid/
6
5
 
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ALPHABET_BASE64_URL = exports.ALPHABET_BASE64 = exports.ALPHABET_ALPHANUMERIC = exports.ALPHABET_ALPHANUMERIC_UPPERCASE = exports.ALPHABET_ALPHANUMERIC_LOWERCASE = exports.ALPHABET_UPPERCASE = exports.ALPHABET_LOWERCASE = exports.ALPHABET_NUMBER = exports.ALPHABET_NONAMBIGUOUS = void 0;
10
- exports.nanoIdCustomAlphabet = nanoIdCustomAlphabet;
11
- exports.nanoid = nanoid;
12
7
  /* eslint-disable */
13
- const node_crypto_1 = require("node:crypto");
14
- exports.ALPHABET_NONAMBIGUOUS = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
15
- exports.ALPHABET_NUMBER = '0123456789';
16
- exports.ALPHABET_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';
17
- exports.ALPHABET_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
18
- exports.ALPHABET_ALPHANUMERIC_LOWERCASE = [exports.ALPHABET_NUMBER, exports.ALPHABET_LOWERCASE].join('');
19
- exports.ALPHABET_ALPHANUMERIC_UPPERCASE = [exports.ALPHABET_NUMBER, exports.ALPHABET_UPPERCASE].join('');
20
- exports.ALPHABET_ALPHANUMERIC = [exports.ALPHABET_NUMBER, exports.ALPHABET_LOWERCASE, exports.ALPHABET_UPPERCASE].join('');
21
- exports.ALPHABET_BASE64 = [exports.ALPHABET_ALPHANUMERIC, '+/'].join('');
22
- exports.ALPHABET_BASE64_URL = [exports.ALPHABET_ALPHANUMERIC, '-_'].join('');
8
+ import { randomFillSync } from 'node:crypto';
9
+ export const ALPHABET_NONAMBIGUOUS = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
10
+ export const ALPHABET_NUMBER = '0123456789';
11
+ export const ALPHABET_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';
12
+ export const ALPHABET_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
13
+ export const ALPHABET_ALPHANUMERIC_LOWERCASE = [ALPHABET_NUMBER, ALPHABET_LOWERCASE].join('');
14
+ export const ALPHABET_ALPHANUMERIC_UPPERCASE = [ALPHABET_NUMBER, ALPHABET_UPPERCASE].join('');
15
+ export const ALPHABET_ALPHANUMERIC = [ALPHABET_NUMBER, ALPHABET_LOWERCASE, ALPHABET_UPPERCASE].join('');
16
+ export const ALPHABET_BASE64 = [ALPHABET_ALPHANUMERIC, '+/'].join('');
17
+ export const ALPHABET_BASE64_URL = [ALPHABET_ALPHANUMERIC, '-_'].join('');
23
18
  // It is best to make fewer, larger requests to the crypto module to
24
19
  // avoid system call overhead. So, random numbers are generated in a
25
20
  // pool. The pool is a Buffer that is larger than the initial random
@@ -31,11 +26,11 @@ let poolOffset;
31
26
  function fillPool(bytes) {
32
27
  if (!pool || pool.length < bytes) {
33
28
  pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
34
- (0, node_crypto_1.randomFillSync)(pool);
29
+ randomFillSync(pool);
35
30
  poolOffset = 0;
36
31
  }
37
32
  else if (poolOffset + bytes > pool.length) {
38
- (0, node_crypto_1.randomFillSync)(pool);
33
+ randomFillSync(pool);
39
34
  poolOffset = 0;
40
35
  }
41
36
  poolOffset += bytes;
@@ -77,10 +72,10 @@ function customRandom(alphabet, defaultSize, getRandom) {
77
72
  }
78
73
  };
79
74
  }
80
- function nanoIdCustomAlphabet(alphabet, size = 21) {
75
+ export function nanoIdCustomAlphabet(alphabet, size = 21) {
81
76
  return customRandom(alphabet, size, random);
82
77
  }
83
- function nanoid(size = 21) {
78
+ export function nanoid(size = 21) {
84
79
  // `-=` convert `size` to number to prevent `valueOf` abusing
85
80
  fillPool((size -= 0));
86
81
  let id = '';
@@ -91,7 +86,7 @@ function nanoid(size = 21) {
91
86
  // range to the 0-63 value range. Therefore, adding hacks, such
92
87
  // as empty string fallback or magic numbers, is unneccessary because
93
88
  // the bitmask trims bytes down to the alphabet size.
94
- id += exports.ALPHABET_BASE64_URL[pool[i] & 63];
89
+ id += ALPHABET_BASE64_URL[pool[i] & 63];
95
90
  }
96
91
  return id;
97
92
  }
@@ -1,16 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadSecretsFromEnv = loadSecretsFromEnv;
4
- exports.removeSecretsFromEnv = removeSecretsFromEnv;
5
- exports.loadSecretsFromEncryptedJsonFile = loadSecretsFromEncryptedJsonFile;
6
- exports.loadSecretsFromEncryptedJsonFileValues = loadSecretsFromEncryptedJsonFileValues;
7
- exports.secret = secret;
8
- exports.secretOptional = secretOptional;
9
- exports.getSecretMap = getSecretMap;
10
- exports.setSecretMap = setSecretMap;
11
- const node_fs_1 = require("node:fs");
12
- const js_lib_1 = require("@naturalcycles/js-lib");
13
- const crypto_util_1 = require("./crypto.util");
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { _assert, _jsonParseIfPossible } from '@naturalcycles/js-lib';
3
+ import { decryptObject, decryptRandomIVBuffer } from './crypto.util.js';
14
4
  let loaded = false;
15
5
  const secretMap = {};
16
6
  /**
@@ -19,8 +9,8 @@ const secretMap = {};
19
9
  *
20
10
  * Does NOT delete previous secrets from secretMap.
21
11
  */
22
- function loadSecretsFromEnv() {
23
- require('dotenv').config(); // ensure .env is loaded
12
+ export function loadSecretsFromEnv() {
13
+ // require('dotenv').config() // ensure .env is loaded
24
14
  const secrets = {};
25
15
  Object.keys(process.env)
26
16
  .filter(k => k.toUpperCase().startsWith('SECRET_'))
@@ -35,7 +25,7 @@ function loadSecretsFromEnv() {
35
25
  /**
36
26
  * Removes process.env.SECRET_*
37
27
  */
38
- function removeSecretsFromEnv() {
28
+ export function removeSecretsFromEnv() {
39
29
  Object.keys(process.env)
40
30
  .filter(k => k.toUpperCase().startsWith('SECRET_'))
41
31
  .forEach(k => delete process.env[k]);
@@ -48,17 +38,17 @@ function removeSecretsFromEnv() {
48
38
  * Whole file is encrypted.
49
39
  * For "json-values encrypted" style - use `loadSecretsFromEncryptedJsonFileValues`
50
40
  */
51
- function loadSecretsFromEncryptedJsonFile(filePath, secretEncryptionKey) {
52
- (0, js_lib_1._assert)((0, node_fs_1.existsSync)(filePath), `loadSecretsFromEncryptedJsonFile() cannot load from path: ${filePath}`);
41
+ export function loadSecretsFromEncryptedJsonFile(filePath, secretEncryptionKey) {
42
+ _assert(existsSync(filePath), `loadSecretsFromEncryptedJsonFile() cannot load from path: ${filePath}`);
53
43
  let secrets;
54
44
  if (secretEncryptionKey) {
55
- const buf = (0, node_fs_1.readFileSync)(filePath);
45
+ const buf = readFileSync(filePath);
56
46
  const encKeyBuffer = Buffer.from(secretEncryptionKey, 'base64');
57
- const plain = (0, crypto_util_1.decryptRandomIVBuffer)(buf, encKeyBuffer).toString('utf8');
47
+ const plain = decryptRandomIVBuffer(buf, encKeyBuffer).toString('utf8');
58
48
  secrets = JSON.parse(plain);
59
49
  }
60
50
  else {
61
- secrets = JSON.parse((0, node_fs_1.readFileSync)(filePath, 'utf8'));
51
+ secrets = JSON.parse(readFileSync(filePath, 'utf8'));
62
52
  }
63
53
  Object.entries(secrets).forEach(([k, v]) => (secretMap[k.toUpperCase()] = v));
64
54
  loaded = true;
@@ -70,12 +60,12 @@ function loadSecretsFromEncryptedJsonFile(filePath, secretEncryptionKey) {
70
60
  * Whole file is NOT encrypted, but instead individual json values ARE encrypted..
71
61
  * For whole-file encryption - use `loadSecretsFromEncryptedJsonFile`
72
62
  */
73
- function loadSecretsFromEncryptedJsonFileValues(filePath, secretEncryptionKey) {
74
- (0, js_lib_1._assert)((0, node_fs_1.existsSync)(filePath), `loadSecretsFromEncryptedJsonFileValues() cannot load from path: ${filePath}`);
75
- let secrets = JSON.parse((0, node_fs_1.readFileSync)(filePath, 'utf8'));
63
+ export function loadSecretsFromEncryptedJsonFileValues(filePath, secretEncryptionKey) {
64
+ _assert(existsSync(filePath), `loadSecretsFromEncryptedJsonFileValues() cannot load from path: ${filePath}`);
65
+ let secrets = JSON.parse(readFileSync(filePath, 'utf8'));
76
66
  if (secretEncryptionKey) {
77
67
  const encKeyBuffer = Buffer.from(secretEncryptionKey, 'base64');
78
- secrets = (0, crypto_util_1.decryptObject)(secrets, encKeyBuffer);
68
+ secrets = decryptObject(secrets, encKeyBuffer);
79
69
  }
80
70
  Object.entries(secrets).forEach(([k, v]) => (secretMap[k.toUpperCase()] = v));
81
71
  loaded = true;
@@ -83,31 +73,31 @@ function loadSecretsFromEncryptedJsonFileValues(filePath, secretEncryptionKey) {
83
73
  .map(s => s.toUpperCase())
84
74
  .join(', ')}`);
85
75
  }
86
- function secret(k, parseJson = false) {
76
+ export function secret(k, parseJson = false) {
87
77
  const v = secretOptional(k, parseJson);
88
78
  if (!v) {
89
79
  throw new Error(`secret(${k.toUpperCase()}) not found!`);
90
80
  }
91
81
  return v;
92
82
  }
93
- function secretOptional(k, parseJson = false) {
83
+ export function secretOptional(k, parseJson = false) {
94
84
  requireLoaded();
95
85
  let v = secretMap[k.toUpperCase()];
96
86
  if (!v)
97
87
  return;
98
88
  if (parseJson) {
99
- v = (0, js_lib_1._jsonParseIfPossible)(v);
89
+ v = _jsonParseIfPossible(v);
100
90
  }
101
91
  return v;
102
92
  }
103
- function getSecretMap() {
93
+ export function getSecretMap() {
104
94
  requireLoaded();
105
95
  return secretMap;
106
96
  }
107
97
  /**
108
98
  * REPLACES secretMap with new map.
109
99
  */
110
- function setSecretMap(map) {
100
+ export function setSecretMap(map) {
111
101
  Object.keys(secretMap).forEach(k => delete secretMap[k]);
112
102
  Object.entries(map).forEach(([k, v]) => (secretMap[k.toUpperCase()] = v));
113
103
  console.log(`setSecretMap set ${Object.keys(secretMap).length} secret(s): ${Object.keys(map)
@@ -1,5 +1,5 @@
1
1
  import type { AnyObject, CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib';
2
- import type { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model';
2
+ import type { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model.js';
3
3
  /**
4
4
  * Has 2 main methods:
5
5
  *
@@ -1,9 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlackService = void 0;
4
- exports.slackDefaultMessagePrefixHook = slackDefaultMessagePrefixHook;
5
- const js_lib_1 = require("@naturalcycles/js-lib");
6
- const __1 = require("..");
1
+ import { _omit, commonLoggerMinLevel, getFetcher, localTime, PQueue } from '@naturalcycles/js-lib';
2
+ import { _inspect } from '../index.js';
7
3
  const GAE = !!process.env['GAE_INSTANCE'];
8
4
  const DEFAULTS = {
9
5
  username: 'bot',
@@ -27,7 +23,7 @@ const INSPECT_OPT = {
27
23
  * .send method has a shortcut:
28
24
  * .send(string, ctx?: CTX)
29
25
  */
30
- class SlackService {
26
+ export class SlackService {
31
27
  constructor(cfg) {
32
28
  this.cfg = {
33
29
  messagePrefixHook: slackDefaultMessagePrefixHook,
@@ -38,7 +34,7 @@ class SlackService {
38
34
  ...cfg.inspectOptions,
39
35
  },
40
36
  };
41
- this.fetcher = (0, js_lib_1.getFetcher)({
37
+ this.fetcher = getFetcher({
42
38
  timeoutSeconds: 90,
43
39
  });
44
40
  }
@@ -72,10 +68,10 @@ class SlackService {
72
68
  let text;
73
69
  // Array has a special treatment here
74
70
  if (Array.isArray(msg.items)) {
75
- text = msg.items.map(t => (0, __1._inspect)(t, inspectOptions)).join('\n');
71
+ text = msg.items.map(t => _inspect(t, inspectOptions)).join('\n');
76
72
  }
77
73
  else {
78
- text = (0, __1._inspect)(msg.items, inspectOptions);
74
+ text = _inspect(msg.items, inspectOptions);
79
75
  }
80
76
  // Wrap in markdown-text-block if it's anything but plain String
81
77
  if (typeof msg.items !== 'string') {
@@ -87,7 +83,7 @@ class SlackService {
87
83
  const prefix = await messagePrefixHook(msg);
88
84
  if (prefix === null)
89
85
  return; // filtered out!
90
- const json = (0, js_lib_1._omit)({
86
+ const json = _omit({
91
87
  ...DEFAULTS,
92
88
  ...this.cfg.defaults,
93
89
  ...msg,
@@ -119,19 +115,18 @@ class SlackService {
119
115
  getCommonLogger(opt) {
120
116
  const { minLogLevel = 'log', logChannel, warnChannel, errorChannel } = opt;
121
117
  const defaultChannel = this.cfg.defaults?.channel || DEFAULTS.channel;
122
- const q = new js_lib_1.PQueue({
118
+ const q = new PQueue({
123
119
  concurrency: 1,
124
120
  });
125
- return (0, js_lib_1.commonLoggerMinLevel)({
121
+ return commonLoggerMinLevel({
126
122
  log: (...args) => q.push(() => this.send({ items: args, channel: logChannel || defaultChannel })),
127
123
  warn: (...args) => q.push(() => this.send({ items: args, channel: warnChannel || defaultChannel })),
128
124
  error: (...args) => q.push(() => this.send({ items: args, channel: errorChannel || defaultChannel })),
129
125
  }, minLogLevel);
130
126
  }
131
127
  }
132
- exports.SlackService = SlackService;
133
- function slackDefaultMessagePrefixHook(msg) {
134
- const tokens = [js_lib_1.localTime.now().toPretty()];
128
+ export function slackDefaultMessagePrefixHook(msg) {
129
+ const tokens = [localTime.now().toPretty()];
135
130
  const { ctx } = msg;
136
131
  // AppEngine-specific decoration
137
132
  if (GAE && ctx && typeof ctx === 'object' && typeof ctx.header === 'function') {
@@ -1,5 +1,5 @@
1
1
  import type { AnyObject, CommonLogger } from '@naturalcycles/js-lib';
2
- import type { InspectAnyOptions } from '..';
2
+ import type { InspectAnyOptions } from '../index.js';
3
3
  /**
4
4
  * Properties that exists both in SlackApiBody (as per Slack API) and SlackMessage (our abstraction).
5
5
  */
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NDJsonStats = void 0;
4
- const js_lib_1 = require("@naturalcycles/js-lib");
5
- const colors_1 = require("../../colors/colors");
6
- class NDJsonStats {
1
+ import { _hb, _ms } from '@naturalcycles/js-lib';
2
+ import { boldWhite, dimWhite } from '../../colors/colors.js';
3
+ export class NDJsonStats {
7
4
  static create(o = {}) {
8
5
  return Object.assign(new NDJsonStats(), o);
9
6
  }
@@ -38,11 +35,10 @@ class NDJsonStats {
38
35
  }
39
36
  toPretty(name) {
40
37
  return [
41
- `Processed ${name ? (0, colors_1.boldWhite)(name) + ': ' : ''}${(0, colors_1.dimWhite)(this.rows)} rows, ${(0, colors_1.dimWhite)((0, js_lib_1._hb)(this.sizeBytes))} in ${(0, colors_1.dimWhite)((0, js_lib_1._ms)(this.tookMillis))}`,
42
- (0, colors_1.dimWhite)(this.rpsTotal + ' rows/sec'),
43
- (0, colors_1.dimWhite)((0, js_lib_1._hb)(this.avgBytesPerRow) + '/row'),
44
- (0, colors_1.dimWhite)((0, js_lib_1._hb)(this.bpsTotal) + '/sec'),
38
+ `Processed ${name ? boldWhite(name) + ': ' : ''}${dimWhite(this.rows)} rows, ${dimWhite(_hb(this.sizeBytes))} in ${dimWhite(_ms(this.tookMillis))}`,
39
+ dimWhite(this.rpsTotal + ' rows/sec'),
40
+ dimWhite(_hb(this.avgBytesPerRow) + '/row'),
41
+ dimWhite(_hb(this.bpsTotal) + '/sec'),
45
42
  ].join(', ');
46
43
  }
47
44
  }
48
- exports.NDJsonStats = NDJsonStats;
@@ -1,5 +1,5 @@
1
1
  import type { AbortableAsyncMapper } from '@naturalcycles/js-lib';
2
- import type { TransformLogProgressOptions, TransformMapOptions } from '../..';
2
+ import type { TransformLogProgressOptions, TransformMapOptions } from '../../index.js';
3
3
  export interface NDJSONMapOptions<IN = any, OUT = IN> extends TransformMapOptions<IN, OUT>, TransformLogProgressOptions<IN> {
4
4
  inputFilePath: string;
5
5
  outputFilePath: string;