@naturalcycles/nodejs-lib 13.44.0 → 13.45.2

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 (162) 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.js +2 -2
  9. package/dist/csv/csvReader.d.ts +1 -1
  10. package/dist/csv/csvWriter.d.ts +1 -1
  11. package/dist/csv/transformToCSV.d.ts +3 -3
  12. package/dist/diff/tableDiff.d.ts +1 -1
  13. package/dist/fs/fs2.d.ts +2 -2
  14. package/dist/fs/fs2.js +14 -14
  15. package/dist/fs/json2env.d.ts +1 -1
  16. package/dist/fs/json2env.js +5 -5
  17. package/dist/fs/kpy.js +8 -8
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +2 -2
  20. package/dist/infra/process.util.js +7 -7
  21. package/dist/jwt/jwt.service.d.ts +3 -3
  22. package/dist/jwt/jwt.service.js +5 -5
  23. package/dist/script/runScript.js +3 -3
  24. package/dist/secret/secrets-decrypt.util.js +4 -4
  25. package/dist/secret/secrets-encrypt.util.js +7 -7
  26. package/dist/security/crypto.util.d.ts +1 -1
  27. package/dist/security/crypto.util.js +9 -9
  28. package/dist/security/hash.util.d.ts +1 -1
  29. package/dist/security/hash.util.js +3 -7
  30. package/dist/security/id.util.js +3 -4
  31. package/dist/security/secret.util.d.ts +1 -1
  32. package/dist/security/secret.util.js +6 -7
  33. package/dist/slack/slack.service.d.ts +2 -2
  34. package/dist/slack/slack.service.model.d.ts +2 -2
  35. package/dist/stream/ndjson/ndjsonMap.d.ts +2 -2
  36. package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +2 -2
  37. package/dist/stream/ndjson/transformJsonParse.d.ts +2 -2
  38. package/dist/stream/ndjson/transformToNDJson.d.ts +1 -1
  39. package/dist/stream/pipeline/pipeline.d.ts +3 -2
  40. package/dist/stream/progressLogger.d.ts +2 -2
  41. package/dist/stream/readable/readableCreate.d.ts +2 -2
  42. package/dist/stream/readable/readableForEach.d.ts +3 -3
  43. package/dist/stream/readable/readableFromArray.d.ts +3 -3
  44. package/dist/stream/readable/readableToArray.d.ts +1 -1
  45. package/dist/stream/sizeStack.d.ts +2 -1
  46. package/dist/stream/stream.util.d.ts +2 -2
  47. package/dist/stream/transform/transformChunk.d.ts +1 -1
  48. package/dist/stream/transform/transformFilter.d.ts +3 -3
  49. package/dist/stream/transform/transformLimit.d.ts +3 -3
  50. package/dist/stream/transform/transformLogProgress.d.ts +2 -2
  51. package/dist/stream/transform/transformMap.d.ts +3 -2
  52. package/dist/stream/transform/transformMapSimple.d.ts +3 -2
  53. package/dist/stream/transform/transformMapSync.d.ts +4 -3
  54. package/dist/stream/transform/transformNoOp.d.ts +1 -1
  55. package/dist/stream/transform/transformOffset.d.ts +1 -1
  56. package/dist/stream/transform/transformSplit.d.ts +1 -1
  57. package/dist/stream/transform/transformTap.d.ts +2 -2
  58. package/dist/stream/transform/transformTee.d.ts +1 -1
  59. package/dist/stream/transform/transformThrottle.d.ts +2 -2
  60. package/dist/stream/transform/transformToArray.d.ts +1 -1
  61. package/dist/stream/transform/worker/baseWorkerClass.d.ts +1 -1
  62. package/dist/stream/transform/worker/transformMultiThreaded.d.ts +2 -2
  63. package/dist/stream/writable/writableForEach.d.ts +3 -3
  64. package/dist/stream/writable/writableFork.d.ts +1 -1
  65. package/dist/stream/writable/writableLimit.d.ts +2 -2
  66. package/dist/stream/writable/writablePushToArray.d.ts +1 -1
  67. package/dist/stream/writable/writableVoid.d.ts +2 -2
  68. package/dist/string/inspect.d.ts +2 -2
  69. package/dist/util/buildInfo.util.d.ts +1 -1
  70. package/dist/util/env.util.js +2 -3
  71. package/dist/util/exec2.d.ts +2 -1
  72. package/dist/util/exec2.js +6 -9
  73. package/dist/util/git2.js +6 -7
  74. package/dist/util/lruMemoCache.d.ts +1 -1
  75. package/dist/util/zip.util.d.ts +1 -1
  76. package/dist/util/zip.util.js +5 -5
  77. package/dist/validation/ajv/ajv.util.d.ts +3 -2
  78. package/dist/validation/ajv/ajvSchema.d.ts +2 -2
  79. package/dist/validation/ajv/ajvValidationError.d.ts +2 -1
  80. package/dist/validation/joi/joi.extensions.d.ts +2 -2
  81. package/dist/validation/joi/joi.shared.schemas.d.ts +4 -4
  82. package/dist/validation/joi/joi.validation.error.d.ts +3 -2
  83. package/dist/validation/joi/joi.validation.util.d.ts +1 -1
  84. package/dist/validation/joi/number.extensions.d.ts +2 -2
  85. package/dist/validation/joi/string.extensions.d.ts +3 -3
  86. package/package.json +1 -1
  87. package/src/bin/generate-build-info.ts +4 -4
  88. package/src/bin/json2env.ts +1 -1
  89. package/src/bin/kpy.ts +1 -1
  90. package/src/bin/secrets-decrypt.ts +3 -2
  91. package/src/bin/secrets-encrypt.ts +3 -2
  92. package/src/bin/secrets-gen-key.ts +3 -3
  93. package/src/bin/slack-this.ts +1 -1
  94. package/src/colors/colors.ts +1 -1
  95. package/src/csv/csvReader.ts +2 -1
  96. package/src/csv/csvWriter.ts +2 -1
  97. package/src/csv/transformToCSV.ts +4 -3
  98. package/src/diff/tableDiff.ts +2 -1
  99. package/src/fs/fs2.ts +4 -3
  100. package/src/fs/json2env.ts +2 -2
  101. package/src/fs/kpy.ts +3 -2
  102. package/src/index.ts +1 -1
  103. package/src/infra/process.util.ts +1 -1
  104. package/src/jwt/jwt.service.ts +4 -3
  105. package/src/script/runScript.ts +1 -1
  106. package/src/secret/secrets-decrypt.util.ts +1 -1
  107. package/src/secret/secrets-encrypt.util.ts +2 -2
  108. package/src/security/crypto.util.ts +3 -2
  109. package/src/security/hash.util.ts +4 -6
  110. package/src/security/id.util.ts +3 -3
  111. package/src/security/secret.util.ts +8 -7
  112. package/src/slack/slack.service.model.ts +2 -2
  113. package/src/slack/slack.service.ts +5 -13
  114. package/src/stream/ndjson/ndjsonMap.ts +4 -10
  115. package/src/stream/ndjson/ndjsonStreamForEach.ts +4 -10
  116. package/src/stream/ndjson/transformJsonParse.ts +2 -2
  117. package/src/stream/ndjson/transformToNDJson.ts +1 -1
  118. package/src/stream/pipeline/pipeline.ts +4 -2
  119. package/src/stream/progressLogger.ts +5 -11
  120. package/src/stream/readable/readableCreate.ts +3 -2
  121. package/src/stream/readable/readableForEach.ts +6 -3
  122. package/src/stream/readable/readableFromArray.ts +5 -3
  123. package/src/stream/readable/readableToArray.ts +1 -1
  124. package/src/stream/sizeStack.ts +2 -1
  125. package/src/stream/stream.util.ts +2 -2
  126. package/src/stream/transform/transformChunk.ts +1 -1
  127. package/src/stream/transform/transformFilter.ts +4 -3
  128. package/src/stream/transform/transformLimit.ts +3 -3
  129. package/src/stream/transform/transformLogProgress.ts +3 -2
  130. package/src/stream/transform/transformMap.ts +10 -8
  131. package/src/stream/transform/transformMapSimple.ts +3 -2
  132. package/src/stream/transform/transformMapSync.ts +4 -12
  133. package/src/stream/transform/transformNoOp.ts +1 -1
  134. package/src/stream/transform/transformOffset.ts +1 -1
  135. package/src/stream/transform/transformSplit.ts +1 -1
  136. package/src/stream/transform/transformTap.ts +2 -2
  137. package/src/stream/transform/transformTee.ts +1 -1
  138. package/src/stream/transform/transformThrottle.ts +3 -6
  139. package/src/stream/transform/transformToArray.ts +1 -1
  140. package/src/stream/transform/worker/baseWorkerClass.ts +1 -1
  141. package/src/stream/transform/worker/transformMultiThreaded.ts +4 -3
  142. package/src/stream/writable/writableForEach.ts +5 -3
  143. package/src/stream/writable/writableFork.ts +3 -2
  144. package/src/stream/writable/writableLimit.ts +3 -2
  145. package/src/stream/writable/writablePushToArray.ts +1 -1
  146. package/src/stream/writable/writableVoid.ts +2 -2
  147. package/src/string/inspect.ts +4 -2
  148. package/src/util/buildInfo.util.ts +2 -7
  149. package/src/util/env.util.ts +2 -2
  150. package/src/util/exec2.ts +18 -25
  151. package/src/util/git2.ts +6 -6
  152. package/src/util/lruMemoCache.ts +1 -1
  153. package/src/util/zip.util.ts +2 -1
  154. package/src/validation/ajv/ajv.util.ts +3 -2
  155. package/src/validation/ajv/ajvSchema.ts +3 -4
  156. package/src/validation/ajv/ajvValidationError.ts +2 -1
  157. package/src/validation/joi/joi.extensions.ts +4 -2
  158. package/src/validation/joi/joi.shared.schemas.ts +10 -8
  159. package/src/validation/joi/joi.validation.error.ts +3 -2
  160. package/src/validation/joi/joi.validation.util.ts +3 -2
  161. package/src/validation/joi/number.extensions.ts +2 -2
  162. package/src/validation/joi/string.extensions.ts +4 -3
@@ -1,16 +1,10 @@
1
- import { inspect, InspectOptions } from 'node:util'
2
- import {
3
- _mb,
4
- _since,
5
- AnyObject,
6
- CommonLogger,
7
- localTime,
8
- SimpleMovingAverage,
9
- UnixTimestampMillis,
10
- } from '@naturalcycles/js-lib'
1
+ import type { InspectOptions } from 'node:util'
2
+ import { inspect } from 'node:util'
3
+ import type { AnyObject, CommonLogger, UnixTimestampMillis } from '@naturalcycles/js-lib'
4
+ import { _mb, _since, localTime, SimpleMovingAverage } from '@naturalcycles/js-lib'
11
5
  import { boldWhite, dimGrey, hasColors, white, yellow } from '../colors/colors'
12
6
  import { SizeStack } from './sizeStack'
13
- import { ReadableMapper } from './stream.model'
7
+ import type { ReadableMapper } from './stream.model'
14
8
 
15
9
  export interface ProgressLoggerCfg<T = any> {
16
10
  /**
@@ -1,5 +1,6 @@
1
- import { Readable, ReadableOptions } from 'node:stream'
2
- import { ReadableTyped } from '../stream.model'
1
+ import type { ReadableOptions } from 'node:stream'
2
+ import { Readable } from 'node:stream'
3
+ import type { ReadableTyped } from '../stream.model'
3
4
 
4
5
  /**
5
6
  * Convenience function to create a Readable that can be pushed into (similar to RxJS Subject).
@@ -1,6 +1,9 @@
1
- import { _passNothingPredicate, AbortableAsyncMapper, Mapper } from '@naturalcycles/js-lib'
2
- import { _pipeline, ReadableTyped } from '../../index'
3
- import { transformMap, TransformMapOptions } from '../transform/transformMap'
1
+ import type { AbortableAsyncMapper, Mapper } from '@naturalcycles/js-lib'
2
+ import { _passNothingPredicate } from '@naturalcycles/js-lib'
3
+ import type { ReadableTyped } from '../../index'
4
+ import { _pipeline } from '../../index'
5
+ import type { TransformMapOptions } from '../transform/transformMap'
6
+ import { transformMap } from '../transform/transformMap'
4
7
 
5
8
  /**
6
9
  * Convenience function to do `.forEach` over a Readable.
@@ -1,6 +1,8 @@
1
- import { Readable, ReadableOptions } from 'node:stream'
2
- import { _passthroughMapper, AbortableAsyncMapper } from '@naturalcycles/js-lib'
3
- import { ReadableTyped } from '../stream.model'
1
+ import type { ReadableOptions } from 'node:stream'
2
+ import { Readable } from 'node:stream'
3
+ import type { AbortableAsyncMapper } from '@naturalcycles/js-lib'
4
+ import { _passthroughMapper } from '@naturalcycles/js-lib'
5
+ import type { ReadableTyped } from '../stream.model'
4
6
 
5
7
  /**
6
8
  * Create Readable from Array.
@@ -1,4 +1,4 @@
1
- import { ReadableTyped } from '../stream.model'
1
+ import type { ReadableTyped } from '../stream.model'
2
2
 
3
3
  /**
4
4
  * Convenience function to read the whole Readable stream into Array (in-memory)
@@ -1,4 +1,5 @@
1
- import { _hb, CommonLogger, NumberStack } from '@naturalcycles/js-lib'
1
+ import type { CommonLogger } from '@naturalcycles/js-lib'
2
+ import { _hb, NumberStack } from '@naturalcycles/js-lib'
2
3
  import { yellow } from '../colors/colors'
3
4
  import { gzipBuffer } from '../util/zip.util'
4
5
 
@@ -1,5 +1,5 @@
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
 
4
4
  export function pipelineClose(
5
5
  name: string,
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import { TransformOptions, TransformTyped } from '../stream.model'
2
+ import type { TransformOptions, TransformTyped } from '../stream.model'
3
3
 
4
4
  export interface TransformChunkOptions extends TransformOptions {
5
5
  /**
@@ -1,7 +1,8 @@
1
1
  import { Transform } from 'node:stream'
2
- import { AsyncPredicate, Predicate } from '@naturalcycles/js-lib'
3
- import { TransformOptions, TransformTyped } from '../stream.model'
4
- import { transformMap, TransformMapOptions } from './transformMap'
2
+ import type { AsyncPredicate, Predicate } from '@naturalcycles/js-lib'
3
+ import type { TransformOptions, TransformTyped } from '../stream.model'
4
+ import type { TransformMapOptions } from './transformMap'
5
+ import { transformMap } from './transformMap'
5
6
 
6
7
  /**
7
8
  * Just a convenience wrapper around `transformMap` that has built-in predicate filtering support.
@@ -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, transformNoOp } from '../../index'
4
- import { TransformOptions, TransformTyped } from '../stream.model'
4
+ import type { TransformOptions, TransformTyped } from '../stream.model'
5
5
  import { pipelineClose } from '../stream.util'
6
6
 
7
7
  export interface TransformLimitOptions extends TransformOptions {
@@ -1,6 +1,7 @@
1
1
  import { Transform } from 'node:stream'
2
- import { progressLogger, ProgressLoggerCfg } from '../progressLogger'
3
- import { TransformOptions, TransformTyped } from '../stream.model'
2
+ import type { ProgressLoggerCfg } from '../progressLogger'
3
+ import { progressLogger } from '../progressLogger'
4
+ import type { TransformOptions, TransformTyped } from '../stream.model'
4
5
 
5
6
  export interface TransformLogProgressOptions<IN = any>
6
7
  extends ProgressLoggerCfg<IN>,
@@ -1,23 +1,25 @@
1
+ import type {
2
+ AbortableAsyncMapper,
3
+ AsyncPredicate,
4
+ CommonLogger,
5
+ Promisable,
6
+ StringMap,
7
+ UnixTimestampMillis,
8
+ } from '@naturalcycles/js-lib'
1
9
  import {
2
10
  _anyToError,
3
11
  _hc,
4
12
  _since,
5
13
  _stringify,
6
- AbortableAsyncMapper,
7
- AsyncPredicate,
8
- CommonLogger,
9
14
  END,
10
15
  ErrorMode,
11
16
  pFilter,
12
- Promisable,
13
17
  SKIP,
14
- StringMap,
15
- UnixTimestampMillis,
16
18
  } from '@naturalcycles/js-lib'
17
19
  import through2Concurrent = require('through2-concurrent')
18
20
  import { yellow } from '../../colors/colors'
19
- import { AbortableTransform } from '../pipeline/pipeline'
20
- import { TransformTyped } from '../stream.model'
21
+ import type { AbortableTransform } from '../pipeline/pipeline'
22
+ import type { TransformTyped } from '../stream.model'
21
23
  import { pipelineClose } from '../stream.util'
22
24
 
23
25
  export interface TransformMapOptions<IN = any, OUT = IN> {
@@ -1,6 +1,7 @@
1
1
  import { Transform } from 'node:stream'
2
- import { CommonLogger, ErrorMode, Mapper } from '@naturalcycles/js-lib'
3
- import { TransformTyped } from '../stream.model'
2
+ import type { CommonLogger, Mapper } from '@naturalcycles/js-lib'
3
+ import { ErrorMode } from '@naturalcycles/js-lib'
4
+ import type { TransformTyped } from '../stream.model'
4
5
 
5
6
  export interface TransformMapSimpleOptions {
6
7
  /**
@@ -1,18 +1,10 @@
1
- import {
2
- _anyToError,
3
- CommonLogger,
4
- END,
5
- ErrorMode,
6
- Mapper,
7
- Predicate,
8
- SKIP,
9
- UnixTimestampMillis,
10
- } from '@naturalcycles/js-lib'
1
+ import type { CommonLogger, Mapper, Predicate, UnixTimestampMillis } from '@naturalcycles/js-lib'
2
+ import { _anyToError, END, ErrorMode, SKIP } from '@naturalcycles/js-lib'
11
3
  import { yellow } from '../../colors/colors'
12
4
  import { AbortableTransform } from '../pipeline/pipeline'
13
- import { TransformTyped } from '../stream.model'
5
+ import type { TransformTyped } from '../stream.model'
14
6
  import { pipelineClose } from '../stream.util'
15
- import { TransformMapStats } from './transformMap'
7
+ import type { TransformMapStats } from './transformMap'
16
8
 
17
9
  export interface TransformMapSyncOptions<IN = any, OUT = IN> {
18
10
  /**
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import { TransformTyped } from '../stream.model'
2
+ import type { TransformTyped } from '../stream.model'
3
3
 
4
4
  /**
5
5
  * Transform that does nothing (pass the data through).
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'node:stream'
2
2
  import { transformNoOp } from '../../index'
3
- import { TransformOptions, TransformTyped } from '../stream.model'
3
+ import type { TransformOptions, TransformTyped } from '../stream.model'
4
4
 
5
5
  export interface TransformOffsetOptions extends TransformOptions {
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import { TransformTyped } from '../stream.model'
2
+ import type { TransformTyped } from '../stream.model'
3
3
 
4
4
  // The code below is carefully adopted from: https://github.com/max-mapper/binary-split
5
5
 
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'node:stream'
2
- import { AsyncMapper, CommonLogger } from '@naturalcycles/js-lib'
3
- import { TransformOptions, TransformTyped } from '../stream.model'
2
+ import type { AsyncMapper, CommonLogger } from '@naturalcycles/js-lib'
3
+ import type { TransformOptions, TransformTyped } from '../stream.model'
4
4
 
5
5
  export interface TransformTapOptions extends TransformOptions {
6
6
  logger?: CommonLogger
@@ -1,7 +1,7 @@
1
1
  import { Transform } from 'node:stream'
2
2
  import { _pipeline } from '../pipeline/pipeline'
3
3
  import { readableCreate } from '../readable/readableCreate'
4
- import { TransformTyped } from '../stream.model'
4
+ import type { TransformTyped } from '../stream.model'
5
5
 
6
6
  type AnyStream = NodeJS.WritableStream | NodeJS.ReadWriteStream
7
7
 
@@ -1,15 +1,12 @@
1
1
  import { Transform } from 'node:stream'
2
- import {
3
- _ms,
4
- _since,
2
+ import type {
5
3
  DeferredPromise,
6
- localTime,
7
4
  NumberOfSeconds,
8
- pDefer,
9
5
  PositiveInteger,
10
6
  UnixTimestampMillis,
11
7
  } from '@naturalcycles/js-lib'
12
- import { TransformTyped } from '../stream.model'
8
+ import { _ms, _since, localTime, pDefer } from '@naturalcycles/js-lib'
9
+ import type { TransformTyped } from '../stream.model'
13
10
 
14
11
  export interface TransformThrottleOptions {
15
12
  /**
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import { TransformOptions, TransformTyped } from '../stream.model'
2
+ import type { TransformOptions, TransformTyped } from '../stream.model'
3
3
 
4
4
  /**
5
5
  * Will collect all stream results in the array (keeping it in memory) and emit in the end as one result.
@@ -1,4 +1,4 @@
1
- import { BaseWorkerData } from './transformMultiThreaded.model'
1
+ import type { BaseWorkerData } from './transformMultiThreaded.model'
2
2
 
3
3
  export interface WorkerClassInterface<
4
4
  IN,
@@ -1,8 +1,9 @@
1
1
  import { Worker } from 'node:worker_threads'
2
- import { _range, AnyObject, DeferredPromise, pDefer } from '@naturalcycles/js-lib'
2
+ import type { AnyObject, DeferredPromise } from '@naturalcycles/js-lib'
3
+ import { _range, pDefer } from '@naturalcycles/js-lib'
3
4
  import through2Concurrent = require('through2-concurrent')
4
- import { TransformTyped } from '../../stream.model'
5
- import { WorkerInput, WorkerOutput } from './transformMultiThreaded.model'
5
+ import type { TransformTyped } from '../../stream.model'
6
+ import type { WorkerInput, WorkerOutput } from './transformMultiThreaded.model'
6
7
 
7
8
  export interface TransformMultiThreadedOptions {
8
9
  /**
@@ -1,6 +1,8 @@
1
- import { _passNothingPredicate, AsyncMapper, Mapper } from '@naturalcycles/js-lib'
2
- import { transformMap, TransformMapOptions, transformMapSync } from '../..'
3
- import { WritableTyped } from '../stream.model'
1
+ import type { AsyncMapper, Mapper } from '@naturalcycles/js-lib'
2
+ import { _passNothingPredicate } from '@naturalcycles/js-lib'
3
+ import type { TransformMapOptions } from '../..'
4
+ import { transformMap, transformMapSync } from '../..'
5
+ import type { WritableTyped } from '../stream.model'
4
6
 
5
7
  /**
6
8
  * Just an alias to transformMap that declares OUT as void.
@@ -1,6 +1,7 @@
1
1
  import { Writable } from 'node:stream'
2
- import { _pipeline, readableCreate, ReadableTyped } from '../..'
3
- import { TransformOptions, WritableTyped } from '../stream.model'
2
+ import type { ReadableTyped } from '../..'
3
+ import { _pipeline, readableCreate } from '../..'
4
+ import type { TransformOptions, WritableTyped } from '../stream.model'
4
5
 
5
6
  /**
6
7
  * Allows "forking" a stream inside pipeline into a number of pipeline chains (2 or more).
@@ -1,5 +1,6 @@
1
- import { Readable, Writable } from 'node:stream'
2
- import { WritableTyped } from '../stream.model'
1
+ import type { Readable } from 'node:stream'
2
+ import { Writable } from 'node:stream'
3
+ import type { WritableTyped } from '../stream.model'
3
4
 
4
5
  /**
5
6
  * Allows to stop the Readable stream after the pipeline has processed X number of rows.
@@ -1,5 +1,5 @@
1
1
  import { Writable } from 'node:stream'
2
- import { TransformOptions, WritableTyped } from '../stream.model'
2
+ import type { TransformOptions, WritableTyped } from '../stream.model'
3
3
 
4
4
  /**
5
5
  * Will push all results to `arr`, will emit nothing in the end.
@@ -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
 
5
5
  export interface WritableVoidOptions extends TransformOptions {
6
6
  /**
@@ -1,5 +1,7 @@
1
- import { inspect, InspectOptions } from 'node:util'
2
- import { _stringify, JsonStringifyFunction, StringifyOptions } from '@naturalcycles/js-lib'
1
+ import type { InspectOptions } from 'node:util'
2
+ import { inspect } from 'node:util'
3
+ import type { JsonStringifyFunction, StringifyOptions } from '@naturalcycles/js-lib'
4
+ import { _stringify } from '@naturalcycles/js-lib'
3
5
 
4
6
  export interface InspectAnyOptions extends StringifyOptions, InspectOptions {}
5
7
 
@@ -1,10 +1,5 @@
1
- import {
2
- _filterUndefinedValues,
3
- AnyObject,
4
- BuildInfo,
5
- localTime,
6
- UnixTimestamp,
7
- } from '@naturalcycles/js-lib'
1
+ import type { AnyObject, BuildInfo, UnixTimestamp } from '@naturalcycles/js-lib'
2
+ import { _filterUndefinedValues, localTime } from '@naturalcycles/js-lib'
8
3
  import { fs2 } from '../fs/fs2'
9
4
  import { git2 } from './git2'
10
5
 
@@ -1,5 +1,5 @@
1
1
  import 'dotenv/config' // ensure .env is read before requiring keys
2
- import fs from 'node:fs'
2
+ import { existsSync } from 'node:fs'
3
3
  import type { ValuesOf } from '@naturalcycles/js-lib'
4
4
 
5
5
  /**
@@ -25,7 +25,7 @@ export function requireEnvKeys<T extends readonly string[]>(
25
25
  }
26
26
 
27
27
  export function requireFileToExist(filePath: string): void {
28
- if (!fs.existsSync(filePath)) {
28
+ if (!existsSync(filePath)) {
29
29
  throw new Error(`Required file should exist: ${filePath}`)
30
30
  }
31
31
  }
package/src/util/exec2.ts CHANGED
@@ -1,11 +1,6 @@
1
- import cp from 'node:child_process'
2
- import {
3
- _since,
4
- AnyObject,
5
- AppError,
6
- NumberOfMilliseconds,
7
- UnixTimestampMillis,
8
- } from '@naturalcycles/js-lib'
1
+ import { execSync, spawn, spawnSync } from 'node:child_process'
2
+ import type { AnyObject, NumberOfMilliseconds, UnixTimestampMillis } from '@naturalcycles/js-lib'
3
+ import { _since, AppError } from '@naturalcycles/js-lib'
9
4
  import { dimGrey, dimRed, hasColors, white } from '../colors/colors'
10
5
 
11
6
  /**
@@ -52,7 +47,7 @@ class Exec2 {
52
47
  const started = Date.now() as UnixTimestampMillis
53
48
  this.logStart(cmd, opt)
54
49
 
55
- const r = cp.spawnSync(cmd, opt.args, {
50
+ const r = spawnSync(cmd, opt.args, {
56
51
  encoding: 'utf8',
57
52
  stdio: 'inherit',
58
53
  shell,
@@ -97,20 +92,18 @@ class Exec2 {
97
92
  this.logStart(cmd, opt)
98
93
 
99
94
  try {
100
- const s = cp
101
- .execSync(cmd, {
102
- encoding: 'utf8',
103
- // stdio: 'inherit', // no, otherwise we don't get the output returned
104
- stdio: undefined,
105
- // shell: undefined,
106
- cwd,
107
- timeout,
108
- env: {
109
- ...(passProcessEnv ? process.env : {}),
110
- ...env,
111
- },
112
- })
113
- .trim()
95
+ const s = execSync(cmd, {
96
+ encoding: 'utf8',
97
+ // stdio: 'inherit', // no, otherwise we don't get the output returned
98
+ stdio: undefined,
99
+ // shell: undefined,
100
+ cwd,
101
+ timeout,
102
+ env: {
103
+ ...(passProcessEnv ? process.env : {}),
104
+ ...env,
105
+ },
106
+ }).trim()
114
107
 
115
108
  this.logFinish(cmd, opt, started, true)
116
109
  return s
@@ -150,7 +143,7 @@ class Exec2 {
150
143
  this.logStart(cmd, opt)
151
144
 
152
145
  await new Promise<void>((resolve, reject) => {
153
- const p = cp.spawn(cmd, opt.args || [], {
146
+ const p = spawn(cmd, opt.args || [], {
154
147
  shell,
155
148
  cwd,
156
149
  stdio: 'inherit',
@@ -211,7 +204,7 @@ class Exec2 {
211
204
  let stderr = ''
212
205
 
213
206
  return await new Promise<SpawnOutput>((resolve, reject) => {
214
- const p = cp.spawn(cmd, opt.args || [], {
207
+ const p = spawn(cmd, opt.args || [], {
215
208
  shell,
216
209
  cwd,
217
210
  env: {
package/src/util/git2.ts CHANGED
@@ -1,5 +1,5 @@
1
- import cp from 'node:child_process'
2
- import path from 'node:path'
1
+ import { execSync } from 'node:child_process'
2
+ import { basename } from 'node:path'
3
3
  import type { UnixTimestamp } from '@naturalcycles/js-lib'
4
4
  import { grey } from '../colors/colors'
5
5
  import { exec2 } from './exec2'
@@ -21,7 +21,7 @@ class Git2 {
21
21
  hasUncommittedChanges(): boolean {
22
22
  // git diff-index --quiet HEAD -- || echo "untracked"
23
23
  try {
24
- cp.execSync('git diff-index --quiet HEAD --', {
24
+ execSync('git diff-index --quiet HEAD --', {
25
25
  encoding: 'utf8',
26
26
  })
27
27
  return false
@@ -41,7 +41,7 @@ class Git2 {
41
41
  console.log(grey(cmd))
42
42
 
43
43
  try {
44
- cp.execSync(cmd, {
44
+ execSync(cmd, {
45
45
  stdio: 'inherit',
46
46
  })
47
47
  return true
@@ -64,7 +64,7 @@ class Git2 {
64
64
  pull(): void {
65
65
  const cmd = 'git pull'
66
66
  try {
67
- cp.execSync(cmd, {
67
+ execSync(cmd, {
68
68
  stdio: 'inherit',
69
69
  })
70
70
  } catch {}
@@ -98,7 +98,7 @@ class Git2 {
98
98
 
99
99
  getCurrentRepoName(): string {
100
100
  const originUrl = exec2.exec('git config --get remote.origin.url')
101
- return path.basename(originUrl, '.git')
101
+ return basename(originUrl, '.git')
102
102
  }
103
103
  }
104
104
 
@@ -1,4 +1,4 @@
1
- import { MemoCache } from '@naturalcycles/js-lib'
1
+ import type { MemoCache } from '@naturalcycles/js-lib'
2
2
  import { LRUCache } from 'lru-cache'
3
3
 
4
4
  // Partial, to be able to provide default `max`
@@ -1,5 +1,6 @@
1
1
  import { promisify } from 'node:util'
2
- import zlib, { ZlibOptions } from 'node:zlib'
2
+ import type { ZlibOptions } from 'node:zlib'
3
+ import * as zlib from 'node:zlib'
3
4
 
4
5
  const deflate = promisify(zlib.deflate.bind(zlib))
5
6
  const inflate = promisify(zlib.inflate.bind(zlib))
@@ -1,7 +1,8 @@
1
- import { JsonSchema } from '@naturalcycles/js-lib'
1
+ import type { JsonSchema } from '@naturalcycles/js-lib'
2
2
  import type { FastGlobOptions } from '../..'
3
3
  import { fastGlob, fs2 } from '../..'
4
- import { AjvSchema, AjvSchemaCfg } from './ajvSchema'
4
+ import type { AjvSchemaCfg } from './ajvSchema'
5
+ import { AjvSchema } from './ajvSchema'
5
6
 
6
7
  /**
7
8
  * Does fs.readFileSync + JSON.parse for ALL files matching the passed `glob` pattern.
@@ -1,13 +1,12 @@
1
+ import type { CommonLogger, JsonSchema, JsonSchemaBuilder } from '@naturalcycles/js-lib'
1
2
  import {
2
3
  _filterNullishValues,
3
4
  _isObject,
4
5
  _substringBefore,
5
- CommonLogger,
6
- JsonSchema,
7
6
  JsonSchemaAnyBuilder,
8
- JsonSchemaBuilder,
9
7
  } from '@naturalcycles/js-lib'
10
- import Ajv, { ValidateFunction } from 'ajv'
8
+ import type { ValidateFunction } from 'ajv'
9
+ import type Ajv from 'ajv'
11
10
  import { _inspect, fs2, requireFileToExist } from '../../index'
12
11
  import { AjvValidationError } from './ajvValidationError'
13
12
  import { getAjv } from './getAjv'
@@ -1,4 +1,5 @@
1
- import { AppError, ErrorData } from '@naturalcycles/js-lib'
1
+ import type { ErrorData } from '@naturalcycles/js-lib'
2
+ import { AppError } from '@naturalcycles/js-lib'
2
3
  import type { ErrorObject } from 'ajv'
3
4
 
4
5
  export interface AjvValidationErrorData extends ErrorData {
@@ -1,6 +1,8 @@
1
1
  import JoiLib from 'joi'
2
- import { numberExtensions, NumberSchema } from './number.extensions'
3
- import { stringExtensions, StringSchema } from './string.extensions'
2
+ import type { NumberSchema } from './number.extensions'
3
+ import { numberExtensions } from './number.extensions'
4
+ import type { StringSchema } from './string.extensions'
5
+ import { stringExtensions } from './string.extensions'
4
6
 
5
7
  export interface ExtendedJoi extends JoiLib.Root {
6
8
  // eslint-disable-next-line id-blacklist
@@ -1,8 +1,4 @@
1
- import {
2
- _numberEnumKeys,
3
- _numberEnumValues,
4
- _stringEnumKeys,
5
- _stringEnumValues,
1
+ import type {
6
2
  BaseDBEntity,
7
3
  IANATimezone,
8
4
  IsoDateTime,
@@ -11,10 +7,16 @@ import {
11
7
  UnixTimestamp,
12
8
  UnixTimestampMillis,
13
9
  } from '@naturalcycles/js-lib'
14
- import { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi'
10
+ import {
11
+ _numberEnumKeys,
12
+ _numberEnumValues,
13
+ _stringEnumKeys,
14
+ _stringEnumValues,
15
+ } from '@naturalcycles/js-lib'
16
+ import type { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi'
15
17
  import { Joi } from './joi.extensions'
16
- import { NumberSchema } from './number.extensions'
17
- import { StringSchema } from './string.extensions'
18
+ import type { NumberSchema } from './number.extensions'
19
+ import type { StringSchema } from './string.extensions'
18
20
 
19
21
  export const booleanSchema = Joi.boolean()
20
22
  export const booleanDefaultToFalseSchema = Joi.boolean().default(false)
@@ -1,5 +1,6 @@
1
- import { AppError, ErrorData } from '@naturalcycles/js-lib'
2
- import { ValidationErrorItem } from 'joi'
1
+ import type { ErrorData } from '@naturalcycles/js-lib'
2
+ import { AppError } from '@naturalcycles/js-lib'
3
+ import type { ValidationErrorItem } from 'joi'
3
4
 
4
5
  /**
5
6
  * Example of ValidationErrorItem:
@@ -7,8 +7,9 @@
7
7
  */
8
8
 
9
9
  import { _hb, _isObject, _truncateMiddle } from '@naturalcycles/js-lib'
10
- import { AnySchema, ValidationError, ValidationOptions } from 'joi'
11
- import { JoiValidationError, JoiValidationErrorData } from './joi.validation.error'
10
+ import type { AnySchema, ValidationError, ValidationOptions } from 'joi'
11
+ import type { JoiValidationErrorData } from './joi.validation.error'
12
+ import { JoiValidationError } from './joi.validation.error'
12
13
 
13
14
  // todo: consider replacing with Tuple of [error, value]
14
15
  export interface JoiValidationResult<T = any> {
@@ -1,5 +1,5 @@
1
- import type Joi from 'joi'
2
- import { Extension, NumberSchema as JoiNumberSchema } from 'joi'
1
+ import type * as Joi from 'joi'
2
+ import type { Extension, NumberSchema as JoiNumberSchema } from 'joi'
3
3
 
4
4
  export interface NumberSchema<TSchema = number> extends JoiNumberSchema<TSchema> {
5
5
  dividable: (q: number) => this