@naturalcycles/nodejs-lib 13.44.0 → 13.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (163) hide show
  1. package/dist/bin/generate-build-info.js +7 -7
  2. package/dist/bin/json2env.js +2 -2
  3. package/dist/bin/kpy.js +2 -2
  4. package/dist/bin/secrets-decrypt.js +2 -2
  5. package/dist/bin/secrets-encrypt.js +2 -2
  6. package/dist/bin/secrets-gen-key.js +4 -4
  7. package/dist/bin/slack-this.js +2 -2
  8. package/dist/colors/colors.d.ts +1 -1
  9. package/dist/colors/colors.js +30 -30
  10. package/dist/csv/csvReader.d.ts +1 -1
  11. package/dist/csv/csvWriter.d.ts +1 -1
  12. package/dist/csv/transformToCSV.d.ts +3 -3
  13. package/dist/diff/tableDiff.d.ts +1 -1
  14. package/dist/fs/fs2.d.ts +2 -2
  15. package/dist/fs/fs2.js +14 -14
  16. package/dist/fs/json2env.d.ts +1 -1
  17. package/dist/fs/json2env.js +5 -5
  18. package/dist/fs/kpy.js +8 -8
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +2 -2
  21. package/dist/infra/process.util.js +7 -7
  22. package/dist/jwt/jwt.service.d.ts +3 -3
  23. package/dist/jwt/jwt.service.js +5 -5
  24. package/dist/script/runScript.js +3 -3
  25. package/dist/secret/secrets-decrypt.util.js +4 -4
  26. package/dist/secret/secrets-encrypt.util.js +7 -7
  27. package/dist/security/crypto.util.d.ts +1 -1
  28. package/dist/security/crypto.util.js +9 -9
  29. package/dist/security/hash.util.d.ts +1 -1
  30. package/dist/security/hash.util.js +3 -7
  31. package/dist/security/id.util.js +3 -4
  32. package/dist/security/secret.util.d.ts +1 -1
  33. package/dist/security/secret.util.js +6 -7
  34. package/dist/slack/slack.service.d.ts +2 -2
  35. package/dist/slack/slack.service.model.d.ts +2 -2
  36. package/dist/stream/ndjson/ndjsonMap.d.ts +2 -2
  37. package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +2 -2
  38. package/dist/stream/ndjson/transformJsonParse.d.ts +2 -2
  39. package/dist/stream/ndjson/transformToNDJson.d.ts +1 -1
  40. package/dist/stream/pipeline/pipeline.d.ts +3 -2
  41. package/dist/stream/progressLogger.d.ts +2 -2
  42. package/dist/stream/readable/readableCreate.d.ts +2 -2
  43. package/dist/stream/readable/readableForEach.d.ts +3 -3
  44. package/dist/stream/readable/readableFromArray.d.ts +3 -3
  45. package/dist/stream/readable/readableToArray.d.ts +1 -1
  46. package/dist/stream/sizeStack.d.ts +2 -1
  47. package/dist/stream/stream.util.d.ts +2 -2
  48. package/dist/stream/transform/transformChunk.d.ts +1 -1
  49. package/dist/stream/transform/transformFilter.d.ts +3 -3
  50. package/dist/stream/transform/transformLimit.d.ts +3 -3
  51. package/dist/stream/transform/transformLogProgress.d.ts +2 -2
  52. package/dist/stream/transform/transformMap.d.ts +3 -2
  53. package/dist/stream/transform/transformMapSimple.d.ts +3 -2
  54. package/dist/stream/transform/transformMapSync.d.ts +4 -3
  55. package/dist/stream/transform/transformNoOp.d.ts +1 -1
  56. package/dist/stream/transform/transformOffset.d.ts +1 -1
  57. package/dist/stream/transform/transformSplit.d.ts +1 -1
  58. package/dist/stream/transform/transformTap.d.ts +2 -2
  59. package/dist/stream/transform/transformTee.d.ts +1 -1
  60. package/dist/stream/transform/transformThrottle.d.ts +2 -2
  61. package/dist/stream/transform/transformToArray.d.ts +1 -1
  62. package/dist/stream/transform/worker/baseWorkerClass.d.ts +1 -1
  63. package/dist/stream/transform/worker/transformMultiThreaded.d.ts +2 -2
  64. package/dist/stream/writable/writableForEach.d.ts +3 -3
  65. package/dist/stream/writable/writableFork.d.ts +1 -1
  66. package/dist/stream/writable/writableLimit.d.ts +2 -2
  67. package/dist/stream/writable/writablePushToArray.d.ts +1 -1
  68. package/dist/stream/writable/writableVoid.d.ts +2 -2
  69. package/dist/string/inspect.d.ts +2 -2
  70. package/dist/util/buildInfo.util.d.ts +1 -1
  71. package/dist/util/env.util.js +2 -3
  72. package/dist/util/exec2.d.ts +2 -1
  73. package/dist/util/exec2.js +6 -9
  74. package/dist/util/git2.js +6 -7
  75. package/dist/util/lruMemoCache.d.ts +1 -1
  76. package/dist/util/zip.util.d.ts +1 -1
  77. package/dist/util/zip.util.js +5 -5
  78. package/dist/validation/ajv/ajv.util.d.ts +3 -2
  79. package/dist/validation/ajv/ajvSchema.d.ts +2 -2
  80. package/dist/validation/ajv/ajvValidationError.d.ts +2 -1
  81. package/dist/validation/joi/joi.extensions.d.ts +2 -2
  82. package/dist/validation/joi/joi.shared.schemas.d.ts +4 -4
  83. package/dist/validation/joi/joi.validation.error.d.ts +3 -2
  84. package/dist/validation/joi/joi.validation.util.d.ts +1 -1
  85. package/dist/validation/joi/number.extensions.d.ts +2 -2
  86. package/dist/validation/joi/string.extensions.d.ts +3 -3
  87. package/package.json +1 -1
  88. package/src/bin/generate-build-info.ts +4 -4
  89. package/src/bin/json2env.ts +1 -1
  90. package/src/bin/kpy.ts +1 -1
  91. package/src/bin/secrets-decrypt.ts +3 -2
  92. package/src/bin/secrets-encrypt.ts +3 -2
  93. package/src/bin/secrets-gen-key.ts +3 -3
  94. package/src/bin/slack-this.ts +1 -1
  95. package/src/colors/colors.ts +2 -2
  96. package/src/csv/csvReader.ts +2 -1
  97. package/src/csv/csvWriter.ts +2 -1
  98. package/src/csv/transformToCSV.ts +4 -3
  99. package/src/diff/tableDiff.ts +2 -1
  100. package/src/fs/fs2.ts +4 -3
  101. package/src/fs/json2env.ts +2 -2
  102. package/src/fs/kpy.ts +3 -2
  103. package/src/index.ts +1 -1
  104. package/src/infra/process.util.ts +1 -1
  105. package/src/jwt/jwt.service.ts +4 -3
  106. package/src/script/runScript.ts +1 -1
  107. package/src/secret/secrets-decrypt.util.ts +1 -1
  108. package/src/secret/secrets-encrypt.util.ts +2 -2
  109. package/src/security/crypto.util.ts +3 -2
  110. package/src/security/hash.util.ts +4 -6
  111. package/src/security/id.util.ts +3 -3
  112. package/src/security/secret.util.ts +8 -7
  113. package/src/slack/slack.service.model.ts +2 -2
  114. package/src/slack/slack.service.ts +5 -13
  115. package/src/stream/ndjson/ndjsonMap.ts +4 -10
  116. package/src/stream/ndjson/ndjsonStreamForEach.ts +4 -10
  117. package/src/stream/ndjson/transformJsonParse.ts +2 -2
  118. package/src/stream/ndjson/transformToNDJson.ts +1 -1
  119. package/src/stream/pipeline/pipeline.ts +4 -2
  120. package/src/stream/progressLogger.ts +5 -11
  121. package/src/stream/readable/readableCreate.ts +3 -2
  122. package/src/stream/readable/readableForEach.ts +6 -3
  123. package/src/stream/readable/readableFromArray.ts +5 -3
  124. package/src/stream/readable/readableToArray.ts +1 -1
  125. package/src/stream/sizeStack.ts +2 -1
  126. package/src/stream/stream.util.ts +2 -2
  127. package/src/stream/transform/transformChunk.ts +1 -1
  128. package/src/stream/transform/transformFilter.ts +4 -3
  129. package/src/stream/transform/transformLimit.ts +3 -3
  130. package/src/stream/transform/transformLogProgress.ts +3 -2
  131. package/src/stream/transform/transformMap.ts +10 -8
  132. package/src/stream/transform/transformMapSimple.ts +3 -2
  133. package/src/stream/transform/transformMapSync.ts +4 -12
  134. package/src/stream/transform/transformNoOp.ts +1 -1
  135. package/src/stream/transform/transformOffset.ts +1 -1
  136. package/src/stream/transform/transformSplit.ts +1 -1
  137. package/src/stream/transform/transformTap.ts +2 -2
  138. package/src/stream/transform/transformTee.ts +1 -1
  139. package/src/stream/transform/transformThrottle.ts +3 -6
  140. package/src/stream/transform/transformToArray.ts +1 -1
  141. package/src/stream/transform/worker/baseWorkerClass.ts +1 -1
  142. package/src/stream/transform/worker/transformMultiThreaded.ts +4 -3
  143. package/src/stream/writable/writableForEach.ts +5 -3
  144. package/src/stream/writable/writableFork.ts +3 -2
  145. package/src/stream/writable/writableLimit.ts +3 -2
  146. package/src/stream/writable/writablePushToArray.ts +1 -1
  147. package/src/stream/writable/writableVoid.ts +2 -2
  148. package/src/string/inspect.ts +4 -2
  149. package/src/util/buildInfo.util.ts +2 -7
  150. package/src/util/env.util.ts +2 -2
  151. package/src/util/exec2.ts +18 -25
  152. package/src/util/git2.ts +6 -6
  153. package/src/util/lruMemoCache.ts +1 -1
  154. package/src/util/zip.util.ts +2 -1
  155. package/src/validation/ajv/ajv.util.ts +3 -2
  156. package/src/validation/ajv/ajvSchema.ts +3 -4
  157. package/src/validation/ajv/ajvValidationError.ts +2 -1
  158. package/src/validation/joi/joi.extensions.ts +4 -2
  159. package/src/validation/joi/joi.shared.schemas.ts +10 -8
  160. package/src/validation/joi/joi.validation.error.ts +3 -2
  161. package/src/validation/joi/joi.validation.util.ts +3 -2
  162. package/src/validation/joi/number.extensions.ts +2 -2
  163. package/src/validation/joi/string.extensions.ts +4 -3
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.secretsEncrypt = secretsEncrypt;
4
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"));
5
+ const fs = tslib_1.__importStar(require("node:fs"));
6
+ const path = tslib_1.__importStar(require("node:path"));
7
7
  const js_lib_1 = require("@naturalcycles/js-lib");
8
8
  const colors_1 = require("../colors/colors");
9
9
  const index_1 = require("../index");
@@ -23,21 +23,21 @@ function secretsEncrypt(pattern, file, encKeyBuffer, del = false, jsonMode = fal
23
23
  let encFilename;
24
24
  filenames.forEach(filename => {
25
25
  if (jsonMode) {
26
- (0, js_lib_1._assert)(filename.endsWith('.plain.json'), `${node_path_1.default.basename(filename)} MUST end with '.plain.json'`);
26
+ (0, js_lib_1._assert)(filename.endsWith('.plain.json'), `${path.basename(filename)} MUST end with '.plain.json'`);
27
27
  encFilename = filename.replace('.plain', '');
28
28
  const json = (0, crypto_util_1.encryptObject)(index_1.fs2.readJson(filename), encKeyBuffer);
29
29
  index_1.fs2.writeJson(encFilename, json, { spaces: 2 });
30
30
  }
31
31
  else {
32
- const plain = node_fs_1.default.readFileSync(filename);
32
+ const plain = fs.readFileSync(filename);
33
33
  const enc = (0, crypto_util_1.encryptRandomIVBuffer)(plain, encKeyBuffer);
34
34
  encFilename = `${filename}.enc`;
35
- node_fs_1.default.writeFileSync(encFilename, enc);
35
+ fs.writeFileSync(encFilename, enc);
36
36
  }
37
37
  if (del) {
38
- node_fs_1.default.unlinkSync(filename);
38
+ fs.unlinkSync(filename);
39
39
  }
40
- console.log(` ${node_path_1.default.basename(filename)} > ${node_path_1.default.basename(encFilename)}`);
40
+ console.log(` ${path.basename(filename)} > ${path.basename(encFilename)}`);
41
41
  });
42
42
  console.log(`encrypted ${(0, colors_1.yellow)(filenames.length)} files in (${(0, colors_1.dimGrey)(pattern.join(' '))})`);
43
43
  }
@@ -1,4 +1,4 @@
1
- import { Base64String, StringMap } from '@naturalcycles/js-lib';
1
+ import type { Base64String, StringMap } from '@naturalcycles/js-lib';
2
2
  /**
3
3
  * Using aes-256-cbc.
4
4
  */
@@ -8,7 +8,7 @@ exports.decryptString = decryptString;
8
8
  exports.encryptString = encryptString;
9
9
  exports.timingSafeStringEqual = timingSafeStringEqual;
10
10
  const tslib_1 = require("tslib");
11
- const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
11
+ const crypto = tslib_1.__importStar(require("node:crypto"));
12
12
  const js_lib_1 = require("@naturalcycles/js-lib");
13
13
  const hash_util_1 = require("./hash.util");
14
14
  const algorithm = 'aes-256-cbc';
@@ -19,8 +19,8 @@ function encryptRandomIVBuffer(input, secretKeyBuffer) {
19
19
  // sha256 to match aes-256 key length
20
20
  const key = (0, hash_util_1.sha256AsBuffer)(secretKeyBuffer);
21
21
  // 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);
22
+ const iv = crypto.randomBytes(16);
23
+ const cipher = crypto.createCipheriv(algorithm, key, iv);
24
24
  return Buffer.concat([iv, cipher.update(input), cipher.final()]);
25
25
  }
26
26
  /**
@@ -32,7 +32,7 @@ function decryptRandomIVBuffer(input, secretKeyBuffer) {
32
32
  // iv is first 16 bytes of encrypted buffer, the rest is payload
33
33
  const iv = input.subarray(0, 16);
34
34
  const payload = input.subarray(16);
35
- const decipher = node_crypto_1.default.createDecipheriv(algorithm, key, iv);
35
+ const decipher = crypto.createDecipheriv(algorithm, key, iv);
36
36
  return Buffer.concat([decipher.update(payload), decipher.final()]);
37
37
  }
38
38
  /**
@@ -43,7 +43,7 @@ function decryptObject(obj, secretKeyBuffer) {
43
43
  const { key, iv } = getCryptoParams(secretKeyBuffer);
44
44
  const r = {};
45
45
  (0, js_lib_1._stringMapEntries)(obj).forEach(([k, v]) => {
46
- const decipher = node_crypto_1.default.createDecipheriv(algorithm, key, iv);
46
+ const decipher = crypto.createDecipheriv(algorithm, key, iv);
47
47
  r[k] = decipher.update(v, 'base64', 'utf8') + decipher.final('utf8');
48
48
  });
49
49
  return r;
@@ -56,7 +56,7 @@ function encryptObject(obj, secretKeyBuffer) {
56
56
  const { key, iv } = getCryptoParams(secretKeyBuffer);
57
57
  const r = {};
58
58
  (0, js_lib_1._stringMapEntries)(obj).forEach(([k, v]) => {
59
- const cipher = node_crypto_1.default.createCipheriv(algorithm, key, iv);
59
+ const cipher = crypto.createCipheriv(algorithm, key, iv);
60
60
  r[k] = cipher.update(v, 'utf8', 'base64') + cipher.final('base64');
61
61
  });
62
62
  return r;
@@ -69,7 +69,7 @@ function encryptObject(obj, secretKeyBuffer) {
69
69
  */
70
70
  function decryptString(str, secretKeyBuffer) {
71
71
  const { key, iv } = getCryptoParams(secretKeyBuffer);
72
- const decipher = node_crypto_1.default.createDecipheriv(algorithm, key, iv);
72
+ const decipher = crypto.createDecipheriv(algorithm, key, iv);
73
73
  return decipher.update(str, 'base64', 'utf8') + decipher.final('utf8');
74
74
  }
75
75
  /**
@@ -80,7 +80,7 @@ function decryptString(str, secretKeyBuffer) {
80
80
  */
81
81
  function encryptString(str, secretKeyBuffer) {
82
82
  const { key, iv } = getCryptoParams(secretKeyBuffer);
83
- const cipher = node_crypto_1.default.createCipheriv(algorithm, key, iv);
83
+ const cipher = crypto.createCipheriv(algorithm, key, iv);
84
84
  return cipher.update(str, 'utf8', 'base64') + cipher.final('base64');
85
85
  }
86
86
  function getCryptoParams(secretKeyBuffer) {
@@ -103,5 +103,5 @@ function getCryptoParams(secretKeyBuffer) {
103
103
  function timingSafeStringEqual(s1, s2) {
104
104
  if (s1 === undefined || s2 === undefined || s1.length !== s2.length)
105
105
  return false;
106
- return node_crypto_1.default.timingSafeEqual(Buffer.from(s1), Buffer.from(s2));
106
+ return crypto.timingSafeEqual(Buffer.from(s1), Buffer.from(s2));
107
107
  }
@@ -1,4 +1,4 @@
1
- import { BinaryToTextEncoding } from 'node:crypto';
1
+ import type { BinaryToTextEncoding } from 'node:crypto';
2
2
  import type { Base64String, Base64UrlString } from '@naturalcycles/js-lib';
3
3
  export declare function md5(s: string | Buffer, outputEncoding?: BinaryToTextEncoding): string;
4
4
  export declare function md5AsBuffer(s: string | Buffer): Buffer;
@@ -16,8 +16,7 @@ exports.stringToBase64 = stringToBase64;
16
16
  exports.stringToBase64Url = stringToBase64Url;
17
17
  exports.bufferToBase64 = bufferToBase64;
18
18
  exports.bufferToBase64Url = bufferToBase64Url;
19
- const tslib_1 = require("tslib");
20
- const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
19
+ const node_crypto_1 = require("node:crypto");
21
20
  function md5(s, outputEncoding = 'hex') {
22
21
  return hash(s, 'md5', outputEncoding);
23
22
  }
@@ -31,13 +30,10 @@ function sha256AsBuffer(s) {
31
30
  return hashAsBuffer(s, 'sha256');
32
31
  }
33
32
  function hash(s, algorithm, outputEncoding = 'hex') {
34
- // https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md#crypto-implement-cryptohash
35
- // Note: crypto.hash is Node 20.12+
36
- return node_crypto_1.default.hash(algorithm, s, outputEncoding);
33
+ return (0, node_crypto_1.hash)(algorithm, s, outputEncoding);
37
34
  }
38
35
  function hashAsBuffer(s, algorithm) {
39
- // Note: crypto.hash is Node 20.12+
40
- return node_crypto_1.default.hash(algorithm, s, 'buffer');
36
+ return (0, node_crypto_1.hash)(algorithm, s, 'buffer');
41
37
  }
42
38
  function base64(s) {
43
39
  return (typeof s === 'string' ? Buffer.from(s) : s).toString('base64');
@@ -5,8 +5,7 @@ exports.stringId = stringId;
5
5
  exports.stringIdBase64 = stringIdBase64;
6
6
  exports.stringIdBase64Url = stringIdBase64Url;
7
7
  exports.stringIdNonAmbiguous = stringIdNonAmbiguous;
8
- const tslib_1 = require("tslib");
9
- const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
8
+ const node_crypto_1 = require("node:crypto");
10
9
  const nanoid_1 = require("./nanoid");
11
10
  /**
12
11
  * Generate cryptographically-secure string id.
@@ -30,7 +29,7 @@ exports.stringIdBase62 = (0, nanoid_1.nanoIdCustomAlphabet)(nanoid_1.ALPHABET_AL
30
29
  * Dividable by 4 lengths produce ids with no padding `=` characters, which is optimal.
31
30
  */
32
31
  function stringIdBase64(size = 16) {
33
- return node_crypto_1.default.randomBytes(size * 0.75).toString('base64');
32
+ return (0, node_crypto_1.randomBytes)(size * 0.75).toString('base64');
34
33
  }
35
34
  /**
36
35
  * Generate a string id of Base64url alphabet: A-Za-z0-9-_
@@ -41,7 +40,7 @@ function stringIdBase64(size = 16) {
41
40
  * Base64url always produces strings without a padding character `=`, by design.
42
41
  */
43
42
  function stringIdBase64Url(size = 16) {
44
- return node_crypto_1.default.randomBytes(size * 0.75).toString('base64url');
43
+ return (0, node_crypto_1.randomBytes)(size * 0.75).toString('base64url');
45
44
  }
46
45
  /**
47
46
  * Generate cryptographically-secure string id with non-ambiguous characters only,
@@ -1,4 +1,4 @@
1
- import { Base64String, StringMap } from '@naturalcycles/js-lib';
1
+ import type { Base64String, StringMap } from '@naturalcycles/js-lib';
2
2
  /**
3
3
  * Loads plaintext secrets from process.env, removes them, stores locally.
4
4
  * Make sure to call this function early on server startup, so secrets are removed from process.env
@@ -8,8 +8,7 @@ exports.secret = secret;
8
8
  exports.secretOptional = secretOptional;
9
9
  exports.getSecretMap = getSecretMap;
10
10
  exports.setSecretMap = setSecretMap;
11
- const tslib_1 = require("tslib");
12
- const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
11
+ const node_fs_1 = require("node:fs");
13
12
  const js_lib_1 = require("@naturalcycles/js-lib");
14
13
  const crypto_util_1 = require("./crypto.util");
15
14
  let loaded = false;
@@ -50,16 +49,16 @@ function removeSecretsFromEnv() {
50
49
  * For "json-values encrypted" style - use `loadSecretsFromEncryptedJsonFileValues`
51
50
  */
52
51
  function loadSecretsFromEncryptedJsonFile(filePath, secretEncryptionKey) {
53
- (0, js_lib_1._assert)(node_fs_1.default.existsSync(filePath), `loadSecretsFromEncryptedJsonFile() cannot load from path: ${filePath}`);
52
+ (0, js_lib_1._assert)((0, node_fs_1.existsSync)(filePath), `loadSecretsFromEncryptedJsonFile() cannot load from path: ${filePath}`);
54
53
  let secrets;
55
54
  if (secretEncryptionKey) {
56
- const buf = node_fs_1.default.readFileSync(filePath);
55
+ const buf = (0, node_fs_1.readFileSync)(filePath);
57
56
  const encKeyBuffer = Buffer.from(secretEncryptionKey, 'base64');
58
57
  const plain = (0, crypto_util_1.decryptRandomIVBuffer)(buf, encKeyBuffer).toString('utf8');
59
58
  secrets = JSON.parse(plain);
60
59
  }
61
60
  else {
62
- secrets = JSON.parse(node_fs_1.default.readFileSync(filePath, 'utf8'));
61
+ secrets = JSON.parse((0, node_fs_1.readFileSync)(filePath, 'utf8'));
63
62
  }
64
63
  Object.entries(secrets).forEach(([k, v]) => (secretMap[k.toUpperCase()] = v));
65
64
  loaded = true;
@@ -72,8 +71,8 @@ function loadSecretsFromEncryptedJsonFile(filePath, secretEncryptionKey) {
72
71
  * For whole-file encryption - use `loadSecretsFromEncryptedJsonFile`
73
72
  */
74
73
  function loadSecretsFromEncryptedJsonFileValues(filePath, secretEncryptionKey) {
75
- (0, js_lib_1._assert)(node_fs_1.default.existsSync(filePath), `loadSecretsFromEncryptedJsonFileValues() cannot load from path: ${filePath}`);
76
- let secrets = JSON.parse(node_fs_1.default.readFileSync(filePath, 'utf8'));
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'));
77
76
  if (secretEncryptionKey) {
78
77
  const encKeyBuffer = Buffer.from(secretEncryptionKey, 'base64');
79
78
  secrets = (0, crypto_util_1.decryptObject)(secrets, encKeyBuffer);
@@ -1,5 +1,5 @@
1
- import { AnyObject, CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib';
2
- import { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model';
1
+ import type { AnyObject, CommonLogger, CommonLogLevel } from '@naturalcycles/js-lib';
2
+ import type { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model';
3
3
  /**
4
4
  * Has 2 main methods:
5
5
  *
@@ -1,5 +1,5 @@
1
- import { AnyObject, CommonLogger } from '@naturalcycles/js-lib';
2
- import { InspectAnyOptions } from '..';
1
+ import type { AnyObject, CommonLogger } from '@naturalcycles/js-lib';
2
+ import type { InspectAnyOptions } from '..';
3
3
  /**
4
4
  * Properties that exists both in SlackApiBody (as per Slack API) and SlackMessage (our abstraction).
5
5
  */
@@ -1,5 +1,5 @@
1
- import { AbortableAsyncMapper } from '@naturalcycles/js-lib';
2
- import { TransformLogProgressOptions, TransformMapOptions } from '../..';
1
+ import type { AbortableAsyncMapper } from '@naturalcycles/js-lib';
2
+ import type { TransformLogProgressOptions, TransformMapOptions } from '../..';
3
3
  export interface NDJSONMapOptions<IN = any, OUT = IN> extends TransformMapOptions<IN, OUT>, TransformLogProgressOptions<IN> {
4
4
  inputFilePath: string;
5
5
  outputFilePath: string;
@@ -1,5 +1,5 @@
1
- import { AbortableAsyncMapper } from '@naturalcycles/js-lib';
2
- import { TransformLogProgressOptions, TransformMapOptions } from '../..';
1
+ import type { AbortableAsyncMapper } from '@naturalcycles/js-lib';
2
+ import type { TransformLogProgressOptions, TransformMapOptions } from '../..';
3
3
  export interface NDJSONStreamForEachOptions<IN = any> extends TransformMapOptions<IN, void>, TransformLogProgressOptions<IN> {
4
4
  inputFilePath: string;
5
5
  }
@@ -1,5 +1,5 @@
1
- import { Reviver } from '@naturalcycles/js-lib';
2
- import { TransformTyped } from '../stream.model';
1
+ import type { Reviver } from '@naturalcycles/js-lib';
2
+ import type { TransformTyped } from '../stream.model';
3
3
  export interface TransformJsonParseOptions {
4
4
  /**
5
5
  * If true - will throw an error on JSON.parse / stringify error
@@ -1,4 +1,4 @@
1
- import { TransformTyped } from '../stream.model';
1
+ import type { TransformTyped } from '../stream.model';
2
2
  export interface TransformToNDJsonOptions {
3
3
  /**
4
4
  * If true - will throw an error on JSON.parse / stringify error
@@ -1,5 +1,6 @@
1
- import { Readable, Transform } from 'node:stream';
2
- import { DeferredPromise } from '@naturalcycles/js-lib';
1
+ import type { Readable } from 'node:stream';
2
+ import { Transform } from 'node:stream';
3
+ import type { DeferredPromise } from '@naturalcycles/js-lib';
3
4
  type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream;
4
5
  export interface PipelineOptions {
5
6
  /**
@@ -1,5 +1,5 @@
1
- import { AnyObject, CommonLogger } from '@naturalcycles/js-lib';
2
- import { ReadableMapper } from './stream.model';
1
+ import type { AnyObject, CommonLogger } from '@naturalcycles/js-lib';
2
+ import type { ReadableMapper } from './stream.model';
3
3
  export interface ProgressLoggerCfg<T = any> {
4
4
  /**
5
5
  * Progress metric
@@ -1,5 +1,5 @@
1
- import { ReadableOptions } from 'node:stream';
2
- import { ReadableTyped } from '../stream.model';
1
+ import type { ReadableOptions } from 'node:stream';
2
+ import type { ReadableTyped } from '../stream.model';
3
3
  /**
4
4
  * Convenience function to create a Readable that can be pushed into (similar to RxJS Subject).
5
5
  * Push `null` to it to complete (similar to RxJS `.complete()`).
@@ -1,6 +1,6 @@
1
- import { AbortableAsyncMapper, Mapper } from '@naturalcycles/js-lib';
2
- import { ReadableTyped } from '../../index';
3
- import { TransformMapOptions } from '../transform/transformMap';
1
+ import type { AbortableAsyncMapper, Mapper } from '@naturalcycles/js-lib';
2
+ import type { ReadableTyped } from '../../index';
3
+ import type { TransformMapOptions } from '../transform/transformMap';
4
4
  /**
5
5
  * Convenience function to do `.forEach` over a Readable.
6
6
  * Typed! (unlike default Readable).
@@ -1,6 +1,6 @@
1
- import { ReadableOptions } from 'node:stream';
2
- import { AbortableAsyncMapper } from '@naturalcycles/js-lib';
3
- import { ReadableTyped } from '../stream.model';
1
+ import type { ReadableOptions } from 'node:stream';
2
+ import type { AbortableAsyncMapper } from '@naturalcycles/js-lib';
3
+ import type { ReadableTyped } from '../stream.model';
4
4
  /**
5
5
  * Create Readable from Array.
6
6
  * Supports a `mapper` function (async) that you can use to e.g create a timer-emitting-readable.
@@ -1,4 +1,4 @@
1
- import { ReadableTyped } from '../stream.model';
1
+ import type { ReadableTyped } from '../stream.model';
2
2
  /**
3
3
  * Convenience function to read the whole Readable stream into Array (in-memory)
4
4
  * and return that array.
@@ -1,4 +1,5 @@
1
- import { CommonLogger, NumberStack } from '@naturalcycles/js-lib';
1
+ import type { CommonLogger } from '@naturalcycles/js-lib';
2
+ import { NumberStack } from '@naturalcycles/js-lib';
2
3
  export declare class SizeStack extends NumberStack {
3
4
  name: string;
4
5
  constructor(name: string, size: number);
@@ -1,3 +1,3 @@
1
- import { Readable } from 'node:stream';
2
- import { CommonLogger } from '@naturalcycles/js-lib';
1
+ import type { Readable } from 'node:stream';
2
+ import type { CommonLogger } from '@naturalcycles/js-lib';
3
3
  export declare function pipelineClose(name: string, readableDownstream: Readable, sourceReadable: Readable | undefined, streamDone: Promise<void> | undefined, logger: CommonLogger): void;
@@ -1,4 +1,4 @@
1
- import { TransformOptions, TransformTyped } from '../stream.model';
1
+ import type { TransformOptions, TransformTyped } from '../stream.model';
2
2
  export interface TransformChunkOptions extends TransformOptions {
3
3
  /**
4
4
  * How many items to include in each chunk.
@@ -1,6 +1,6 @@
1
- import { AsyncPredicate, Predicate } from '@naturalcycles/js-lib';
2
- import { TransformOptions, TransformTyped } from '../stream.model';
3
- import { TransformMapOptions } from './transformMap';
1
+ import type { AsyncPredicate, Predicate } from '@naturalcycles/js-lib';
2
+ import type { TransformOptions, TransformTyped } from '../stream.model';
3
+ import type { TransformMapOptions } from './transformMap';
4
4
  /**
5
5
  * Just a convenience wrapper around `transformMap` that has built-in predicate filtering support.
6
6
  */
@@ -1,7 +1,7 @@
1
- import { Readable } from 'node:stream';
2
- import { CommonLogger } from '@naturalcycles/js-lib';
1
+ import type { Readable } from 'node:stream';
2
+ import type { CommonLogger } from '@naturalcycles/js-lib';
3
3
  import { AbortableTransform } from '../../index';
4
- import { TransformOptions, TransformTyped } from '../stream.model';
4
+ import type { TransformOptions, TransformTyped } from '../stream.model';
5
5
  export interface TransformLimitOptions extends TransformOptions {
6
6
  /**
7
7
  * Nullish value (e.g 0 or undefined) would mean "no limit"
@@ -1,5 +1,5 @@
1
- import { ProgressLoggerCfg } from '../progressLogger';
2
- import { TransformOptions, TransformTyped } from '../stream.model';
1
+ import type { ProgressLoggerCfg } from '../progressLogger';
2
+ import type { TransformOptions, TransformTyped } from '../stream.model';
3
3
  export interface TransformLogProgressOptions<IN = any> extends ProgressLoggerCfg<IN>, TransformOptions {
4
4
  }
5
5
  /**
@@ -1,5 +1,6 @@
1
- import { AbortableAsyncMapper, AsyncPredicate, CommonLogger, END, ErrorMode, Promisable, SKIP, StringMap, UnixTimestampMillis } from '@naturalcycles/js-lib';
2
- import { TransformTyped } from '../stream.model';
1
+ import type { AbortableAsyncMapper, AsyncPredicate, CommonLogger, Promisable, StringMap, UnixTimestampMillis } from '@naturalcycles/js-lib';
2
+ import { END, ErrorMode, SKIP } from '@naturalcycles/js-lib';
3
+ import type { TransformTyped } from '../stream.model';
3
4
  export interface TransformMapOptions<IN = any, OUT = IN> {
4
5
  /**
5
6
  * Set true to support "multiMap" - possibility to return [] and emit 1 result for each item in the array.
@@ -1,5 +1,6 @@
1
- import { CommonLogger, ErrorMode, Mapper } from '@naturalcycles/js-lib';
2
- import { TransformTyped } from '../stream.model';
1
+ import type { CommonLogger, Mapper } from '@naturalcycles/js-lib';
2
+ import { ErrorMode } from '@naturalcycles/js-lib';
3
+ import type { TransformTyped } from '../stream.model';
3
4
  export interface TransformMapSimpleOptions {
4
5
  /**
5
6
  * Only supports THROW_IMMEDIATELY (default) and SUPPRESS.
@@ -1,7 +1,8 @@
1
- import { CommonLogger, END, ErrorMode, Mapper, Predicate, SKIP } from '@naturalcycles/js-lib';
1
+ import type { CommonLogger, Mapper, Predicate } from '@naturalcycles/js-lib';
2
+ import { END, ErrorMode, SKIP } from '@naturalcycles/js-lib';
2
3
  import { AbortableTransform } from '../pipeline/pipeline';
3
- import { TransformTyped } from '../stream.model';
4
- import { TransformMapStats } from './transformMap';
4
+ import type { TransformTyped } from '../stream.model';
5
+ import type { TransformMapStats } from './transformMap';
5
6
  export interface TransformMapSyncOptions<IN = any, OUT = IN> {
6
7
  /**
7
8
  * @default true
@@ -1,4 +1,4 @@
1
- import { TransformTyped } from '../stream.model';
1
+ import type { TransformTyped } from '../stream.model';
2
2
  /**
3
3
  * Transform that does nothing (pass the data through).
4
4
  * Can be used e.g to convert "not-valid" stream (e.g one that `transformMap` is producing)
@@ -1,4 +1,4 @@
1
- import { TransformOptions, TransformTyped } from '../stream.model';
1
+ import type { TransformOptions, TransformTyped } from '../stream.model';
2
2
  export interface TransformOffsetOptions extends TransformOptions {
3
3
  /**
4
4
  * How many items to skip (offset) in the stream.
@@ -1,4 +1,4 @@
1
- import { TransformTyped } from '../stream.model';
1
+ import type { TransformTyped } from '../stream.model';
2
2
  /**
3
3
  * Transforms input Buffer/string stream into Buffer chunks (objectMode: true) split by newLine.
4
4
  *
@@ -1,5 +1,5 @@
1
- import { AsyncMapper, CommonLogger } from '@naturalcycles/js-lib';
2
- import { TransformOptions, TransformTyped } from '../stream.model';
1
+ import type { AsyncMapper, CommonLogger } from '@naturalcycles/js-lib';
2
+ import type { TransformOptions, TransformTyped } from '../stream.model';
3
3
  export interface TransformTapOptions extends TransformOptions {
4
4
  logger?: CommonLogger;
5
5
  }
@@ -1,4 +1,4 @@
1
- import { TransformTyped } from '../stream.model';
1
+ import type { TransformTyped } from '../stream.model';
2
2
  type AnyStream = NodeJS.WritableStream | NodeJS.ReadWriteStream;
3
3
  /**
4
4
  * Allows to "tee"/"fork" away from the "main pipeline" into the "secondary pipeline".
@@ -1,5 +1,5 @@
1
- import { NumberOfSeconds, PositiveInteger } from '@naturalcycles/js-lib';
2
- import { TransformTyped } from '../stream.model';
1
+ import type { NumberOfSeconds, PositiveInteger } from '@naturalcycles/js-lib';
2
+ import type { TransformTyped } from '../stream.model';
3
3
  export interface TransformThrottleOptions {
4
4
  /**
5
5
  * How many items to allow per `interval` of seconds.
@@ -1,4 +1,4 @@
1
- import { TransformOptions, TransformTyped } from '../stream.model';
1
+ import type { TransformOptions, TransformTyped } from '../stream.model';
2
2
  /**
3
3
  * Will collect all stream results in the array (keeping it in memory) and emit in the end as one result.
4
4
  */
@@ -1,4 +1,4 @@
1
- import { BaseWorkerData } from './transformMultiThreaded.model';
1
+ import type { BaseWorkerData } from './transformMultiThreaded.model';
2
2
  export interface WorkerClassInterface<IN, OUT, WORKER_DATA extends BaseWorkerData = BaseWorkerData> {
3
3
  WorkerClass: BaseWorkerClass<IN, OUT, WORKER_DATA>;
4
4
  }
@@ -1,5 +1,5 @@
1
- import { AnyObject } from '@naturalcycles/js-lib';
2
- import { TransformTyped } from '../../stream.model';
1
+ import type { AnyObject } from '@naturalcycles/js-lib';
2
+ import type { TransformTyped } from '../../stream.model';
3
3
  export interface TransformMultiThreadedOptions {
4
4
  /**
5
5
  * Absolute path to a js file with worker code
@@ -1,6 +1,6 @@
1
- import { AsyncMapper, Mapper } from '@naturalcycles/js-lib';
2
- import { TransformMapOptions } from '../..';
3
- import { WritableTyped } from '../stream.model';
1
+ import type { AsyncMapper, Mapper } from '@naturalcycles/js-lib';
2
+ import type { TransformMapOptions } from '../..';
3
+ import type { WritableTyped } from '../stream.model';
4
4
  /**
5
5
  * Just an alias to transformMap that declares OUT as void.
6
6
  */
@@ -1,4 +1,4 @@
1
- import { TransformOptions, WritableTyped } from '../stream.model';
1
+ import type { TransformOptions, WritableTyped } from '../stream.model';
2
2
  /**
3
3
  * Allows "forking" a stream inside pipeline into a number of pipeline chains (2 or more).
4
4
  * Currently does NOT (!) maintain backpressure.
@@ -1,5 +1,5 @@
1
- import { Readable } from 'node:stream';
2
- import { WritableTyped } from '../stream.model';
1
+ import type { Readable } from 'node:stream';
2
+ import type { WritableTyped } from '../stream.model';
3
3
  /**
4
4
  * Allows to stop the Readable stream after the pipeline has processed X number of rows.
5
5
  * It counts OUTPUT rows (not input), because this Writable is always at the end of the Pipeline.
@@ -1,4 +1,4 @@
1
- import { TransformOptions, WritableTyped } from '../stream.model';
1
+ import type { TransformOptions, WritableTyped } from '../stream.model';
2
2
  /**
3
3
  * Will push all results to `arr`, will emit nothing in the end.
4
4
  */
@@ -1,6 +1,6 @@
1
1
  import { Writable } from 'node:stream';
2
- import { DeferredPromise } from '@naturalcycles/js-lib';
3
- import { TransformOptions } from '../stream.model';
2
+ import type { DeferredPromise } from '@naturalcycles/js-lib';
3
+ import type { TransformOptions } from '../stream.model';
4
4
  export interface WritableVoidOptions extends TransformOptions {
5
5
  /**
6
6
  * If set - it will be Resolved when the Stream is done (after final.cb)
@@ -1,5 +1,5 @@
1
- import { InspectOptions } from 'node:util';
2
- import { JsonStringifyFunction, StringifyOptions } from '@naturalcycles/js-lib';
1
+ import type { InspectOptions } from 'node:util';
2
+ import type { JsonStringifyFunction, StringifyOptions } from '@naturalcycles/js-lib';
3
3
  export interface InspectAnyOptions extends StringifyOptions, InspectOptions {
4
4
  }
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { BuildInfo, UnixTimestamp } from '@naturalcycles/js-lib';
1
+ import type { BuildInfo, UnixTimestamp } from '@naturalcycles/js-lib';
2
2
  export interface GenerateBuildInfoOptions {
3
3
  /**
4
4
  * If set - this timestamp will be used, instead of "current time".
@@ -2,9 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireEnvKeys = requireEnvKeys;
4
4
  exports.requireFileToExist = requireFileToExist;
5
- const tslib_1 = require("tslib");
6
5
  require("dotenv/config"); // ensure .env is read before requiring keys
7
- const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
6
+ const node_fs_1 = require("node:fs");
8
7
  /**
9
8
  * @example
10
9
  *
@@ -23,7 +22,7 @@ function requireEnvKeys(...keys) {
23
22
  }, {});
24
23
  }
25
24
  function requireFileToExist(filePath) {
26
- if (!node_fs_1.default.existsSync(filePath)) {
25
+ if (!(0, node_fs_1.existsSync)(filePath)) {
27
26
  throw new Error(`Required file should exist: ${filePath}`);
28
27
  }
29
28
  }
@@ -1,4 +1,5 @@
1
- import { AnyObject, AppError, NumberOfMilliseconds } from '@naturalcycles/js-lib';
1
+ import type { AnyObject, NumberOfMilliseconds } from '@naturalcycles/js-lib';
2
+ import { AppError } from '@naturalcycles/js-lib';
2
3
  /**
3
4
  * Set of utility functions to work with Spawn / Exec.
4
5
  *