@naturalcycles/nodejs-lib 12.77.0 → 12.78.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 (95) hide show
  1. package/dist/bin/secrets-gen-key.js +1 -1
  2. package/dist/colors/colors.js +1 -1
  3. package/dist/fs/kpy.js +1 -1
  4. package/dist/got/getGot.js +2 -2
  5. package/dist/infra/process.util.js +1 -1
  6. package/dist/secret/secrets-decrypt.util.js +1 -1
  7. package/dist/secret/secrets-encrypt.util.js +1 -1
  8. package/dist/security/crypto.util.d.ts +7 -7
  9. package/dist/security/crypto.util.js +1 -1
  10. package/dist/security/hash.util.d.ts +7 -12
  11. package/dist/security/hash.util.js +2 -8
  12. package/dist/security/secret.util.d.ts +3 -3
  13. package/dist/security/secret.util.js +1 -1
  14. package/dist/stream/ndjson/ndjsonMap.js +6 -6
  15. package/dist/stream/ndjson/ndjsonStreamForEach.js +3 -3
  16. package/dist/stream/ndjson/pipelineFromNDJsonFile.d.ts +1 -1
  17. package/dist/stream/ndjson/pipelineFromNDJsonFile.js +2 -2
  18. package/dist/stream/ndjson/pipelineToNDJsonFile.d.ts +1 -1
  19. package/dist/stream/ndjson/pipelineToNDJsonFile.js +2 -2
  20. package/dist/stream/ndjson/transformJsonParse.js +2 -2
  21. package/dist/stream/ndjson/transformToNDJson.js +2 -2
  22. package/dist/stream/pipeline/pipeline.d.ts +1 -1
  23. package/dist/stream/pipeline/pipeline.js +3 -3
  24. package/dist/stream/readable/readableCreate.d.ts +1 -1
  25. package/dist/stream/readable/readableCreate.js +3 -3
  26. package/dist/stream/readable/readableFromArray.d.ts +1 -1
  27. package/dist/stream/readable/readableFromArray.js +2 -2
  28. package/dist/stream/readable/readableMap.js +2 -2
  29. package/dist/stream/stream.model.d.ts +1 -1
  30. package/dist/stream/stream.util.d.ts +1 -1
  31. package/dist/stream/transform/transformBuffer.js +2 -2
  32. package/dist/stream/transform/transformFilter.js +2 -2
  33. package/dist/stream/transform/transformLimit.d.ts +1 -1
  34. package/dist/stream/transform/transformLogProgress.js +4 -4
  35. package/dist/stream/transform/transformMapSimple.js +2 -2
  36. package/dist/stream/transform/transformNoOp.js +2 -2
  37. package/dist/stream/transform/transformTap.js +2 -2
  38. package/dist/stream/transform/transformToArray.js +2 -2
  39. package/dist/stream/transform/transformToString.js +2 -2
  40. package/dist/stream/transform/worker/transformMultiThreaded.js +2 -2
  41. package/dist/stream/writable/writableFork.js +2 -2
  42. package/dist/stream/writable/writableLimit.d.ts +1 -1
  43. package/dist/stream/writable/writableLimit.js +2 -2
  44. package/dist/stream/writable/writablePushToArray.js +2 -2
  45. package/dist/stream/writable/writableVoid.d.ts +1 -1
  46. package/dist/stream/writable/writableVoid.js +2 -2
  47. package/dist/string/inspectAny.d.ts +1 -1
  48. package/dist/string/inspectAny.js +3 -3
  49. package/dist/util/env.util.js +1 -1
  50. package/dist/util/zip.util.d.ts +1 -1
  51. package/dist/util/zip.util.js +6 -6
  52. package/dist/validation/ajv/ajv.util.js +1 -1
  53. package/dist/validation/ajv/ajvSchema.js +1 -1
  54. package/package.json +1 -1
  55. package/src/bin/secrets-gen-key.ts +1 -1
  56. package/src/colors/colors.ts +1 -1
  57. package/src/fs/kpy.ts +1 -1
  58. package/src/got/getGot.ts +1 -1
  59. package/src/infra/process.util.ts +1 -1
  60. package/src/secret/secrets-decrypt.util.ts +1 -1
  61. package/src/secret/secrets-encrypt.util.ts +1 -1
  62. package/src/security/crypto.util.ts +8 -8
  63. package/src/security/hash.util.ts +9 -14
  64. package/src/security/secret.util.ts +4 -4
  65. package/src/stream/ndjson/ndjsonMap.ts +2 -2
  66. package/src/stream/ndjson/ndjsonStreamForEach.ts +2 -2
  67. package/src/stream/ndjson/pipelineFromNDJsonFile.ts +1 -1
  68. package/src/stream/ndjson/pipelineToNDJsonFile.ts +1 -1
  69. package/src/stream/ndjson/transformJsonParse.ts +1 -1
  70. package/src/stream/ndjson/transformToNDJson.ts +1 -1
  71. package/src/stream/pipeline/pipeline.ts +1 -1
  72. package/src/stream/readable/readableCreate.ts +1 -1
  73. package/src/stream/readable/readableFromArray.ts +1 -1
  74. package/src/stream/readable/readableMap.ts +1 -1
  75. package/src/stream/stream.model.ts +1 -1
  76. package/src/stream/stream.util.ts +1 -1
  77. package/src/stream/transform/transformBuffer.ts +1 -1
  78. package/src/stream/transform/transformFilter.ts +1 -1
  79. package/src/stream/transform/transformLimit.ts +1 -1
  80. package/src/stream/transform/transformLogProgress.ts +2 -2
  81. package/src/stream/transform/transformMapSimple.ts +1 -1
  82. package/src/stream/transform/transformNoOp.ts +1 -1
  83. package/src/stream/transform/transformTap.ts +1 -1
  84. package/src/stream/transform/transformToArray.ts +1 -1
  85. package/src/stream/transform/transformToString.ts +1 -1
  86. package/src/stream/transform/worker/transformMultiThreaded.ts +1 -1
  87. package/src/stream/writable/writableFork.ts +1 -1
  88. package/src/stream/writable/writableLimit.ts +1 -1
  89. package/src/stream/writable/writablePushToArray.ts +1 -1
  90. package/src/stream/writable/writableVoid.ts +1 -1
  91. package/src/string/inspectAny.ts +1 -1
  92. package/src/util/env.util.ts +1 -1
  93. package/src/util/zip.util.ts +3 -3
  94. package/src/validation/ajv/ajv.util.ts +1 -1
  95. package/src/validation/ajv/ajvSchema.ts +1 -1
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformToString = void 0;
4
- const stream_1 = require("stream");
4
+ const node_stream_1 = require("node:stream");
5
5
  /**
6
6
  * Transforms objectMode=false Buffers/strings into objectMode=true strings.
7
7
  *
@@ -12,7 +12,7 @@ const stream_1 = require("stream");
12
12
  * transformToString(), // string chunks, but objectMode==true
13
13
  */
14
14
  function transformToString() {
15
- return new stream_1.Transform({
15
+ return new node_stream_1.Transform({
16
16
  objectMode: false,
17
17
  readableObjectMode: true,
18
18
  transform(chunk, _, cb) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformMultiThreaded = void 0;
4
- const worker_threads_1 = require("worker_threads");
4
+ const node_worker_threads_1 = require("node:worker_threads");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const through2Concurrent = require("through2-concurrent");
7
7
  const workerProxyFilePath = `${__dirname}/workerClassProxy.js`;
@@ -25,7 +25,7 @@ function transformMultiThreaded(opt) {
25
25
  let index = -1; // input chunk index, will start from 0
26
26
  const workers = (0, js_lib_1._range)(0, poolSize).map(workerIndex => {
27
27
  workerDonePromises.push((0, js_lib_1.pDefer)());
28
- const worker = new worker_threads_1.Worker(workerProxyFilePath, {
28
+ const worker = new node_worker_threads_1.Worker(workerProxyFilePath, {
29
29
  workerData: {
30
30
  workerIndex,
31
31
  workerFile,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writableFork = void 0;
4
- const stream_1 = require("stream");
4
+ const node_stream_1 = require("node:stream");
5
5
  const __1 = require("../..");
6
6
  /**
7
7
  * Allows "forking" a stream inside pipeline into a number of pipeline chains (2 or more).
@@ -21,7 +21,7 @@ function writableFork(chains, opt) {
21
21
  console.error(err); // ensure the error is logged
22
22
  throw err;
23
23
  });
24
- return new stream_1.Writable({
24
+ return new node_stream_1.Writable({
25
25
  objectMode: true,
26
26
  ...opt,
27
27
  write(chunk, _, cb) {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Readable } from 'stream';
2
+ import { Readable } from 'node:stream';
3
3
  import { WritableTyped } from '../stream.model';
4
4
  /**
5
5
  * Allows to stop the Readable stream after the pipeline has processed X number of rows.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writableLimit = void 0;
4
- const stream_1 = require("stream");
4
+ const node_stream_1 = require("node:stream");
5
5
  /**
6
6
  * Allows to stop the Readable stream after the pipeline has processed X number of rows.
7
7
  * It counts OUTPUT rows (not input), because this Writable is always at the end of the Pipeline.
@@ -9,7 +9,7 @@ const stream_1 = require("stream");
9
9
  */
10
10
  function writableLimit(readable, limit) {
11
11
  let i = 0;
12
- return new stream_1.Writable({
12
+ return new node_stream_1.Writable({
13
13
  objectMode: true,
14
14
  write(chunk, _, cb) {
15
15
  if (limit === 0)
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writablePushToArray = void 0;
4
- const stream_1 = require("stream");
4
+ const node_stream_1 = require("node:stream");
5
5
  /**
6
6
  * Will push all results to `arr`, will emit nothing in the end.
7
7
  */
8
8
  function writablePushToArray(arr, opt = {}) {
9
- return new stream_1.Writable({
9
+ return new node_stream_1.Writable({
10
10
  objectMode: true,
11
11
  ...opt,
12
12
  write(chunk, _, cb) {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Writable } from 'stream';
2
+ import { Writable } from 'node:stream';
3
3
  import { DeferredPromise } from '@naturalcycles/js-lib';
4
4
  import { TransformOptions } from '../stream.model';
5
5
  export interface WritableVoidOptions extends TransformOptions {
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.writableVoid = void 0;
4
- const stream_1 = require("stream");
4
+ const node_stream_1 = require("node:stream");
5
5
  /**
6
6
  * Use as a "null-terminator" of stream.pipeline.
7
7
  * It consumes the stream as quickly as possible without doing anything.
8
8
  * Put it in the end of your pipeline in case it ends with Transform that needs a consumer.
9
9
  */
10
10
  function writableVoid(opt = {}) {
11
- return new stream_1.Writable({
11
+ return new node_stream_1.Writable({
12
12
  objectMode: true,
13
13
  ...opt,
14
14
  write(chunk, _, cb) {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { InspectOptions } from 'util';
2
+ import { InspectOptions } from 'node:util';
3
3
  import { StringifyAnyOptions, JsonStringifyFunction } from '@naturalcycles/js-lib';
4
4
  export interface InspectAnyOptions extends StringifyAnyOptions, InspectOptions {
5
5
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.inspectAny = exports.inspectAnyStringifyFn = void 0;
4
- const util_1 = require("util");
4
+ const node_util_1 = require("node:util");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const INSPECT_OPT = {
7
7
  breakLength: 80,
@@ -32,14 +32,14 @@ exports.inspectAnyStringifyFn = inspectAnyStringifyFn;
32
32
  function inspectAny(obj, opt = {}) {
33
33
  // Inspect handles functions better
34
34
  if (typeof obj === 'function') {
35
- return (0, util_1.inspect)(obj, {
35
+ return (0, node_util_1.inspect)(obj, {
36
36
  ...INSPECT_OPT,
37
37
  ...opt,
38
38
  });
39
39
  }
40
40
  return (0, js_lib_1._stringifyAny)(obj, {
41
41
  ...opt,
42
- stringifyFn: obj => (0, util_1.inspect)(obj, {
42
+ stringifyFn: obj => (0, node_util_1.inspect)(obj, {
43
43
  ...INSPECT_OPT,
44
44
  ...opt,
45
45
  }),
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireFileToExist = exports.requireEnvKeys = void 0;
4
- const fs = require("fs");
4
+ const fs = require("node:fs");
5
5
  require("dotenv/config"); // ensure .env is read before requiring keys
6
6
  /**
7
7
  * @example
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { ZlibOptions } from 'zlib';
3
+ import { ZlibOptions } from 'node:zlib';
4
4
  /**
5
5
  * deflateBuffer uses `deflate`.
6
6
  * It's 9 bytes shorter than `gzip`.
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.gunzipToString = exports.gzipString = exports.gunzipBuffer = exports.gzipBuffer = exports.inflateToString = exports.deflateString = exports.inflateBuffer = exports.deflateBuffer = void 0;
4
- const util_1 = require("util");
5
- const zlib = require("zlib");
6
- const deflate = (0, util_1.promisify)(zlib.deflate.bind(zlib));
7
- const inflate = (0, util_1.promisify)(zlib.inflate.bind(zlib));
8
- const gzip = (0, util_1.promisify)(zlib.gzip.bind(zlib));
9
- const gunzip = (0, util_1.promisify)(zlib.gunzip.bind(zlib));
4
+ const node_util_1 = require("node:util");
5
+ const zlib = require("node:zlib");
6
+ const deflate = (0, node_util_1.promisify)(zlib.deflate.bind(zlib));
7
+ const inflate = (0, node_util_1.promisify)(zlib.inflate.bind(zlib));
8
+ const gzip = (0, node_util_1.promisify)(zlib.gzip.bind(zlib));
9
+ const gunzip = (0, node_util_1.promisify)(zlib.gunzip.bind(zlib));
10
10
  // string > compressed buffer
11
11
  /**
12
12
  * deflateBuffer uses `deflate`.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readAjvSchemas = exports.readJsonSchemas = void 0;
4
- const fs = require("fs");
4
+ const fs = require("node:fs");
5
5
  const __1 = require("../..");
6
6
  const ajvSchema_1 = require("./ajvSchema");
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AjvSchema = void 0;
4
- const fs = require("fs");
4
+ const fs = require("node:fs");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const index_1 = require("../../index");
7
7
  const ajvValidationError_1 = require("./ajvValidationError");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "12.77.0",
3
+ "version": "12.78.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as crypto from 'crypto'
3
+ import * as crypto from 'node:crypto'
4
4
  import * as yargs from 'yargs'
5
5
  import { dimGrey } from '../colors'
6
6
  import { runScript } from '../script'
@@ -1,4 +1,4 @@
1
- import * as tty from 'tty'
1
+ import * as tty from 'node:tty'
2
2
 
3
3
  /**
4
4
  * Based on: https://github.com/sindresorhus/yoctocolors/pull/5
package/src/fs/kpy.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as path from 'path'
1
+ import * as path from 'node:path'
2
2
  import { _since } from '@naturalcycles/js-lib'
3
3
  import * as cpFile from 'cp-file'
4
4
  import * as fs from 'fs-extra'
package/src/got/getGot.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { URL } from 'url'
1
+ import { URL } from 'node:url'
2
2
  import { _since } from '@naturalcycles/js-lib'
3
3
  import got, {
4
4
  AfterResponseHook,
@@ -1,4 +1,4 @@
1
- import * as os from 'os'
1
+ import * as os from 'node:os'
2
2
  import { _mb } from '@naturalcycles/js-lib'
3
3
 
4
4
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
@@ -1,4 +1,4 @@
1
- import * as path from 'path'
1
+ import * as path from 'node:path'
2
2
  import { _assert } from '@naturalcycles/js-lib'
3
3
  import * as fs from 'fs-extra'
4
4
  import { dimGrey, yellow } from '../colors'
@@ -1,4 +1,4 @@
1
- import * as path from 'path'
1
+ import * as path from 'node:path'
2
2
  import { _assert } from '@naturalcycles/js-lib'
3
3
  import * as fs from 'fs-extra'
4
4
  import { dimGrey, yellow } from '../colors'
@@ -1,5 +1,5 @@
1
- import * as crypto from 'crypto'
2
- import { _stringMapEntries, StringMap } from '@naturalcycles/js-lib'
1
+ import * as crypto from 'node:crypto'
2
+ import { _stringMapEntries, Base64String, StringMap } from '@naturalcycles/js-lib'
3
3
  import { md5 } from './hash.util'
4
4
 
5
5
  const algorithm = 'aes-256-cbc'
@@ -7,7 +7,7 @@ const algorithm = 'aes-256-cbc'
7
7
  /**
8
8
  * Using aes-256-cbc
9
9
  */
10
- export function encryptRandomIVBuffer(input: Buffer, secretKeyBase64: string): Buffer {
10
+ export function encryptRandomIVBuffer(input: Buffer, secretKeyBase64: Base64String): Buffer {
11
11
  // md5 to match aes-256 key length of 32 bytes
12
12
  const key = md5(Buffer.from(secretKeyBase64, 'base64'))
13
13
 
@@ -21,7 +21,7 @@ export function encryptRandomIVBuffer(input: Buffer, secretKeyBase64: string): B
21
21
  /**
22
22
  * Using aes-256-cbc
23
23
  */
24
- export function decryptRandomIVBuffer(input: Buffer, secretKeyBase64: string): Buffer {
24
+ export function decryptRandomIVBuffer(input: Buffer, secretKeyBase64: Base64String): Buffer {
25
25
  // md5 to match aes-256 key length of 32 bytes
26
26
  const key = md5(Buffer.from(secretKeyBase64, 'base64'))
27
27
 
@@ -38,7 +38,7 @@ export function decryptRandomIVBuffer(input: Buffer, secretKeyBase64: string): B
38
38
  * Decrypts all object values.
39
39
  * Returns object with decrypted values.
40
40
  */
41
- export function decryptObject(obj: StringMap, secretKey: string): StringMap {
41
+ export function decryptObject(obj: StringMap<Base64String>, secretKey: string): StringMap {
42
42
  const { key, iv } = getCryptoParams(secretKey)
43
43
 
44
44
  const r: StringMap = {}
@@ -49,7 +49,7 @@ export function decryptObject(obj: StringMap, secretKey: string): StringMap {
49
49
  return r
50
50
  }
51
51
 
52
- export function encryptObject(obj: StringMap, secretKey: string): StringMap {
52
+ export function encryptObject(obj: StringMap, secretKey: string): StringMap<Base64String> {
53
53
  const { key, iv } = getCryptoParams(secretKey)
54
54
 
55
55
  const r: StringMap = {}
@@ -63,7 +63,7 @@ export function encryptObject(obj: StringMap, secretKey: string): StringMap {
63
63
  /**
64
64
  * Using aes-256-cbc
65
65
  */
66
- export function decryptString(str: string, secretKey: string): string {
66
+ export function decryptString(str: Base64String, secretKey: string): string {
67
67
  const { key, iv } = getCryptoParams(secretKey)
68
68
  const decipher = crypto.createDecipheriv(algorithm, key, iv)
69
69
  return decipher.update(str, 'base64', 'utf8') + decipher.final('utf8')
@@ -72,7 +72,7 @@ export function decryptString(str: string, secretKey: string): string {
72
72
  /**
73
73
  * Using aes-256-cbc
74
74
  */
75
- export function encryptString(str: string, secretKey: string): string {
75
+ export function encryptString(str: string, secretKey: string): Base64String {
76
76
  const { key, iv } = getCryptoParams(secretKey)
77
77
  const cipher = crypto.createCipheriv(algorithm, key, iv)
78
78
  return cipher.update(str, 'utf8', 'base64') + cipher.final('base64')
@@ -1,10 +1,11 @@
1
- import * as crypto from 'crypto'
1
+ import * as crypto from 'node:crypto'
2
+ import { Base64String } from '@naturalcycles/js-lib'
2
3
 
3
4
  export function md5(s: string | Buffer): string {
4
5
  return hash(s, 'md5')
5
6
  }
6
7
 
7
- export function md5AsBase64(s: string | Buffer): string {
8
+ export function md5AsBase64(s: string | Buffer): Base64String {
8
9
  return hashAsBuffer(s, 'md5').toString('base64')
9
10
  }
10
11
 
@@ -16,7 +17,7 @@ export function sha256(s: string | Buffer): string {
16
17
  return hash(s, 'sha256')
17
18
  }
18
19
 
19
- export function sha256AsBase64(s: string | Buffer): string {
20
+ export function sha256AsBase64(s: string | Buffer): Base64String {
20
21
  return hashAsBuffer(s, 'sha256').toString('base64')
21
22
  }
22
23
 
@@ -32,11 +33,11 @@ export function hashAsBuffer(s: string | Buffer, algorithm: string): Buffer {
32
33
  return crypto.createHash(algorithm).update(s).digest()
33
34
  }
34
35
 
35
- export function base64(s: string | Buffer): string {
36
- return (Buffer.isBuffer(s) ? s : Buffer.from(s, 'utf8')).toString('base64')
36
+ export function base64(s: string | Buffer): Base64String {
37
+ return (typeof s === 'string' ? Buffer.from(s) : s).toString('base64')
37
38
  }
38
39
 
39
- export function base64ToString(strBase64: string): string {
40
+ export function base64ToString(strBase64: Base64String): string {
40
41
  return Buffer.from(strBase64, 'base64').toString('utf8')
41
42
  }
42
43
 
@@ -44,16 +45,10 @@ export function base64ToBuffer(strBase64: string): Buffer {
44
45
  return Buffer.from(strBase64, 'base64')
45
46
  }
46
47
 
47
- /**
48
- * @deprecated use `base64`
49
- */
50
- export function stringToBase64(s: string): string {
48
+ export function stringToBase64(s: string): Base64String {
51
49
  return Buffer.from(s, 'utf8').toString('base64')
52
50
  }
53
51
 
54
- /**
55
- * @deprecated use `base64`
56
- */
57
- export function bufferToBase64(b: Buffer): string {
52
+ export function bufferToBase64(b: Buffer): Base64String {
58
53
  return b.toString('base64')
59
54
  }
@@ -1,5 +1,5 @@
1
- import * as fs from 'fs'
2
- import { _assert, StringMap } from '@naturalcycles/js-lib'
1
+ import * as fs from 'node:fs'
2
+ import { _assert, Base64String, StringMap } from '@naturalcycles/js-lib'
3
3
  import { base64ToString } from '..'
4
4
  import { decryptObject, decryptRandomIVBuffer } from './crypto.util'
5
5
 
@@ -53,7 +53,7 @@ export function removeSecretsFromEnv(): void {
53
53
  // eslint-disable-next-line @typescript-eslint/naming-convention
54
54
  export function loadSecretsFromEncryptedJsonFile(
55
55
  filePath: string,
56
- secretEncryptionKey?: string,
56
+ secretEncryptionKey?: Base64String,
57
57
  ): void {
58
58
  _assert(
59
59
  fs.existsSync(filePath),
@@ -86,7 +86,7 @@ export function loadSecretsFromEncryptedJsonFile(
86
86
  */
87
87
  export function loadSecretsFromEncryptedJsonFileValues(
88
88
  filePath: string,
89
- secretEncryptionKey?: string,
89
+ secretEncryptionKey?: Base64String,
90
90
  ): void {
91
91
  _assert(
92
92
  fs.existsSync(filePath),
@@ -1,5 +1,5 @@
1
- import { createReadStream, createWriteStream } from 'fs'
2
- import { createGzip, createUnzip } from 'zlib'
1
+ import { createReadStream, createWriteStream } from 'node:fs'
2
+ import { createGzip, createUnzip } from 'node:zlib'
3
3
  import { AbortableAsyncMapper, ErrorMode } from '@naturalcycles/js-lib'
4
4
  import {
5
5
  requireFileToExist,
@@ -1,5 +1,5 @@
1
- import * as fs from 'fs'
2
- import { createUnzip } from 'zlib'
1
+ import * as fs from 'node:fs'
2
+ import { createUnzip } from 'node:zlib'
3
3
  import { AbortableAsyncMapper, ErrorMode } from '@naturalcycles/js-lib'
4
4
  import {
5
5
  requireFileToExist,
@@ -1,4 +1,4 @@
1
- import { createUnzip, ZlibOptions } from 'zlib'
1
+ import { createUnzip, ZlibOptions } from 'node:zlib'
2
2
  import { _hb } from '@naturalcycles/js-lib'
3
3
  import * as fs from 'fs-extra'
4
4
  import { transformTap, _pipeline, transformSplit } from '../..'
@@ -1,4 +1,4 @@
1
- import { createGzip, ZlibOptions } from 'zlib'
1
+ import { createGzip, ZlibOptions } from 'node:zlib'
2
2
  import { AppError } from '@naturalcycles/js-lib'
3
3
  import * as fs from 'fs-extra'
4
4
  import { transformTap, _pipeline } from '../..'
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { Reviver } from '@naturalcycles/js-lib'
3
3
  import { TransformTyped } from '../stream.model'
4
4
 
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { _sortObjectDeep } from '@naturalcycles/js-lib'
3
3
  import { TransformTyped } from '../stream.model'
4
4
 
@@ -1,4 +1,4 @@
1
- import { pipeline, Readable, Transform, Writable } from 'stream'
1
+ import { pipeline, Readable, Transform, Writable } from 'node:stream'
2
2
  import { _last, AnyFunction, DeferredPromise, pDefer } from '@naturalcycles/js-lib'
3
3
  import { writablePushToArray } from '../../index'
4
4
 
@@ -1,4 +1,4 @@
1
- import { Readable, ReadableOptions } from 'stream'
1
+ import { Readable, ReadableOptions } from 'node:stream'
2
2
  import { ReadableTyped } from '../stream.model'
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Readable, ReadableOptions } from 'stream'
1
+ import { Readable, ReadableOptions } from 'node:stream'
2
2
  import { _passthroughMapper, AbortableAsyncMapper } from '@naturalcycles/js-lib'
3
3
  import { ReadableTyped } from '../stream.model'
4
4
 
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { AbortableAsyncMapper, SKIP } from '@naturalcycles/js-lib'
3
3
  import { ReadableTyped } from '../stream.model'
4
4
 
@@ -1,4 +1,4 @@
1
- import { Readable, Transform, Writable } from 'stream'
1
+ import { Readable, Transform, Writable } from 'node:stream'
2
2
 
3
3
  // eslint-disable-next-line unused-imports/no-unused-vars
4
4
  export interface ReadableTyped<T> extends Readable {}
@@ -1,4 +1,4 @@
1
- import { Readable } from 'stream'
1
+ import { Readable } from 'node:stream'
2
2
  import { CommonLogger } from '@naturalcycles/js-lib'
3
3
 
4
4
  export function pipelineClose(
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { TransformOptions, TransformTyped } from '../stream.model'
3
3
 
4
4
  export interface TransformBufferOptions extends TransformOptions {
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { AsyncPredicate, Predicate } from '@naturalcycles/js-lib'
3
3
  import { TransformOptions, TransformTyped } from '../stream.model'
4
4
  import { transformMap, TransformMapOptions } from './transformMap'
@@ -1,4 +1,4 @@
1
- import { Readable } from 'stream'
1
+ import { Readable } from 'node:stream'
2
2
  import { CommonLogger } from '@naturalcycles/js-lib'
3
3
  import { AbortableTransform, transformNoOp } from '../../index'
4
4
  import { TransformOptions, TransformTyped } from '../stream.model'
@@ -1,5 +1,5 @@
1
- import { Transform } from 'stream'
2
- import { inspect, InspectOptions } from 'util'
1
+ import { Transform } from 'node:stream'
2
+ import { inspect, InspectOptions } from 'node:util'
3
3
  import {
4
4
  SimpleMovingAverage,
5
5
  _mb,
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { CommonLogger, ErrorMode, Mapper } from '@naturalcycles/js-lib'
3
3
  import { TransformTyped } from '../stream.model'
4
4
 
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { TransformTyped } from '../stream.model'
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { AsyncMapper, CommonLogger } from '@naturalcycles/js-lib'
3
3
  import { TransformOptions, TransformTyped } from '../stream.model'
4
4
 
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { TransformOptions, TransformTyped } from '../stream.model'
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Transform } from 'stream'
1
+ import { Transform } from 'node:stream'
2
2
  import { TransformTyped } from '../stream.model'
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Worker } from 'worker_threads'
1
+ import { Worker } from 'node:worker_threads'
2
2
  import { DeferredPromise, pDefer, _range, AnyObject } from '@naturalcycles/js-lib'
3
3
  import through2Concurrent = require('through2-concurrent')
4
4
  import { TransformTyped } from '../../stream.model'
@@ -1,4 +1,4 @@
1
- import { Writable } from 'stream'
1
+ import { Writable } from 'node:stream'
2
2
  import { readableCreate, ReadableTyped, _pipeline } from '../..'
3
3
  import { TransformOptions, WritableTyped } from '../stream.model'
4
4
 
@@ -1,4 +1,4 @@
1
- import { Readable, Writable } from 'stream'
1
+ import { Readable, Writable } from 'node:stream'
2
2
  import { WritableTyped } from '../stream.model'
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Writable } from 'stream'
1
+ import { Writable } from 'node:stream'
2
2
  import { TransformOptions, WritableTyped } from '../stream.model'
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { Writable } from 'stream'
1
+ import { Writable } from 'node:stream'
2
2
  import { DeferredPromise } from '@naturalcycles/js-lib'
3
3
  import { TransformOptions } from '../stream.model'
4
4
 
@@ -1,4 +1,4 @@
1
- import { inspect, InspectOptions } from 'util'
1
+ import { inspect, InspectOptions } from 'node:util'
2
2
  import { StringifyAnyOptions, _stringifyAny, JsonStringifyFunction } from '@naturalcycles/js-lib'
3
3
 
4
4
  export interface InspectAnyOptions extends StringifyAnyOptions, InspectOptions {}
@@ -1,4 +1,4 @@
1
- import * as fs from 'fs'
1
+ import * as fs from 'node:fs'
2
2
  import type { ValuesOf } from '@naturalcycles/js-lib'
3
3
  import 'dotenv/config' // ensure .env is read before requiring keys
4
4