@naturalcycles/nodejs-lib 13.45.3 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (197) hide show
  1. package/dist/bin/generate-build-info.js +15 -18
  2. package/dist/bin/json2env.js +6 -9
  3. package/dist/bin/kpy.js +6 -9
  4. package/dist/bin/secrets-decrypt.d.ts +1 -1
  5. package/dist/bin/secrets-decrypt.js +9 -12
  6. package/dist/bin/secrets-encrypt.d.ts +1 -1
  7. package/dist/bin/secrets-encrypt.js +9 -12
  8. package/dist/bin/secrets-gen-key.js +8 -11
  9. package/dist/bin/slack-this.js +6 -9
  10. package/dist/buffer/buffer.util.js +1 -4
  11. package/dist/colors/colors.d.ts +26 -27
  12. package/dist/colors/colors.js +29 -33
  13. package/dist/csv/csvReader.js +4 -8
  14. package/dist/csv/csvWriter.js +7 -12
  15. package/dist/csv/transformToCSV.d.ts +2 -2
  16. package/dist/csv/transformToCSV.js +5 -8
  17. package/dist/diff/tableDiff.js +4 -7
  18. package/dist/fs/fs2.d.ts +1 -1
  19. package/dist/fs/fs2.js +88 -94
  20. package/dist/fs/json2env.js +18 -28
  21. package/dist/fs/kpy.js +28 -33
  22. package/dist/index.d.ts +71 -71
  23. package/dist/index.js +73 -78
  24. package/dist/infra/process.util.js +23 -28
  25. package/dist/jwt/jwt.service.js +17 -21
  26. package/dist/log/log.util.js +4 -7
  27. package/dist/script/runScript.js +11 -15
  28. package/dist/secret/secrets-decrypt.util.js +18 -22
  29. package/dist/secret/secrets-encrypt.util.js +17 -21
  30. package/dist/security/crypto.util.js +24 -34
  31. package/dist/security/hash.util.js +19 -37
  32. package/dist/security/id.util.js +11 -18
  33. package/dist/security/nanoid.js +15 -20
  34. package/dist/security/secret.util.js +20 -30
  35. package/dist/slack/slack.service.d.ts +1 -1
  36. package/dist/slack/slack.service.js +13 -16
  37. package/dist/slack/slack.service.model.d.ts +1 -1
  38. package/dist/slack/slack.service.model.js +1 -2
  39. package/dist/stream/ndjson/ndjson.model.js +10 -16
  40. package/dist/stream/ndjson/ndjsonMap.d.ts +1 -1
  41. package/dist/stream/ndjson/ndjsonMap.js +11 -14
  42. package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +1 -1
  43. package/dist/stream/ndjson/ndjsonStreamForEach.js +9 -12
  44. package/dist/stream/ndjson/transformJsonParse.d.ts +1 -1
  45. package/dist/stream/ndjson/transformJsonParse.js +4 -9
  46. package/dist/stream/ndjson/transformToNDJson.d.ts +1 -1
  47. package/dist/stream/ndjson/transformToNDJson.js +5 -8
  48. package/dist/stream/pipeline/pipeline.js +13 -17
  49. package/dist/stream/progressLogger.d.ts +1 -1
  50. package/dist/stream/progressLogger.js +32 -28
  51. package/dist/stream/readable/readableCreate.d.ts +1 -1
  52. package/dist/stream/readable/readableCreate.js +5 -9
  53. package/dist/stream/readable/readableForEach.d.ts +2 -2
  54. package/dist/stream/readable/readableForEach.js +7 -11
  55. package/dist/stream/readable/readableFromArray.d.ts +1 -1
  56. package/dist/stream/readable/readableFromArray.js +4 -7
  57. package/dist/stream/readable/readableToArray.d.ts +1 -1
  58. package/dist/stream/readable/readableToArray.js +1 -4
  59. package/dist/stream/sizeStack.js +9 -12
  60. package/dist/stream/stream.model.js +1 -2
  61. package/dist/stream/stream.util.js +1 -4
  62. package/dist/stream/transform/transformChunk.d.ts +1 -1
  63. package/dist/stream/transform/transformChunk.js +3 -6
  64. package/dist/stream/transform/transformFilter.d.ts +2 -2
  65. package/dist/stream/transform/transformFilter.js +6 -10
  66. package/dist/stream/transform/transformLimit.d.ts +2 -2
  67. package/dist/stream/transform/transformLimit.js +6 -11
  68. package/dist/stream/transform/transformLogProgress.d.ts +2 -2
  69. package/dist/stream/transform/transformLogProgress.js +5 -8
  70. package/dist/stream/transform/transformMap.d.ts +1 -1
  71. package/dist/stream/transform/transformMap.js +18 -22
  72. package/dist/stream/transform/transformMapSimple.d.ts +1 -1
  73. package/dist/stream/transform/transformMapSimple.js +6 -9
  74. package/dist/stream/transform/transformMapSync.d.ts +3 -3
  75. package/dist/stream/transform/transformMapSync.js +14 -19
  76. package/dist/stream/transform/transformNoOp.d.ts +1 -1
  77. package/dist/stream/transform/transformNoOp.js +3 -6
  78. package/dist/stream/transform/transformOffset.d.ts +1 -1
  79. package/dist/stream/transform/transformOffset.js +5 -8
  80. package/dist/stream/transform/transformSplit.d.ts +1 -1
  81. package/dist/stream/transform/transformSplit.js +5 -9
  82. package/dist/stream/transform/transformTap.d.ts +1 -1
  83. package/dist/stream/transform/transformTap.js +3 -6
  84. package/dist/stream/transform/transformTee.d.ts +1 -1
  85. package/dist/stream/transform/transformTee.js +7 -10
  86. package/dist/stream/transform/transformThrottle.d.ts +1 -1
  87. package/dist/stream/transform/transformThrottle.js +9 -12
  88. package/dist/stream/transform/transformToArray.d.ts +1 -1
  89. package/dist/stream/transform/transformToArray.js +3 -6
  90. package/dist/stream/transform/worker/baseWorkerClass.d.ts +1 -1
  91. package/dist/stream/transform/worker/baseWorkerClass.js +2 -5
  92. package/dist/stream/transform/worker/transformMultiThreaded.d.ts +1 -1
  93. package/dist/stream/transform/worker/transformMultiThreaded.js +12 -11
  94. package/dist/stream/transform/worker/transformMultiThreaded.model.js +1 -2
  95. package/dist/stream/transform/worker/workerClassProxy.js +6 -4
  96. package/dist/stream/writable/writableForEach.d.ts +2 -2
  97. package/dist/stream/writable/writableForEach.js +6 -10
  98. package/dist/stream/writable/writableFork.d.ts +1 -1
  99. package/dist/stream/writable/writableFork.js +6 -9
  100. package/dist/stream/writable/writableLimit.d.ts +1 -1
  101. package/dist/stream/writable/writableLimit.js +3 -6
  102. package/dist/stream/writable/writablePushToArray.d.ts +1 -1
  103. package/dist/stream/writable/writablePushToArray.js +3 -6
  104. package/dist/stream/writable/writableVoid.d.ts +1 -1
  105. package/dist/stream/writable/writableVoid.js +3 -6
  106. package/dist/string/inspect.js +8 -13
  107. package/dist/util/buildInfo.util.js +12 -15
  108. package/dist/util/env.util.js +5 -9
  109. package/dist/util/exec2.js +17 -21
  110. package/dist/util/git2.js +17 -20
  111. package/dist/util/lruMemoCache.js +4 -7
  112. package/dist/util/zip.util.js +14 -25
  113. package/dist/validation/ajv/ajv.util.d.ts +3 -3
  114. package/dist/validation/ajv/ajv.util.js +6 -10
  115. package/dist/validation/ajv/ajvSchema.d.ts +2 -2
  116. package/dist/validation/ajv/ajvSchema.js +17 -18
  117. package/dist/validation/ajv/ajvValidationError.js +2 -6
  118. package/dist/validation/ajv/getAjv.d.ts +1 -1
  119. package/dist/validation/ajv/getAjv.js +9 -9
  120. package/dist/validation/joi/joi.extensions.d.ts +2 -2
  121. package/dist/validation/joi/joi.extensions.js +6 -10
  122. package/dist/validation/joi/joi.model.js +1 -2
  123. package/dist/validation/joi/joi.shared.schemas.d.ts +2 -2
  124. package/dist/validation/joi/joi.shared.schemas.js +61 -74
  125. package/dist/validation/joi/joi.validation.error.js +2 -6
  126. package/dist/validation/joi/joi.validation.util.d.ts +1 -1
  127. package/dist/validation/joi/joi.validation.util.js +10 -17
  128. package/dist/validation/joi/number.extensions.js +1 -4
  129. package/dist/validation/joi/string.extensions.js +4 -7
  130. package/dist/yargs.util.js +5 -8
  131. package/package.json +5 -4
  132. package/src/bin/generate-build-info.ts +3 -3
  133. package/src/bin/json2env.ts +2 -2
  134. package/src/bin/kpy.ts +2 -2
  135. package/src/bin/secrets-decrypt.ts +7 -8
  136. package/src/bin/secrets-encrypt.ts +7 -8
  137. package/src/bin/secrets-gen-key.ts +2 -2
  138. package/src/bin/slack-this.ts +2 -2
  139. package/src/csv/transformToCSV.ts +3 -3
  140. package/src/fs/fs2.ts +4 -4
  141. package/src/fs/json2env.ts +2 -2
  142. package/src/fs/kpy.ts +2 -2
  143. package/src/index.ts +71 -71
  144. package/src/jwt/jwt.service.ts +2 -2
  145. package/src/log/log.util.ts +1 -1
  146. package/src/script/runScript.ts +4 -3
  147. package/src/secret/secrets-decrypt.util.ts +3 -3
  148. package/src/secret/secrets-encrypt.util.ts +3 -3
  149. package/src/security/crypto.util.ts +1 -1
  150. package/src/security/id.util.ts +1 -1
  151. package/src/security/secret.util.ts +2 -2
  152. package/src/slack/slack.service.model.ts +1 -1
  153. package/src/slack/slack.service.ts +3 -3
  154. package/src/stream/ndjson/ndjson.model.ts +1 -1
  155. package/src/stream/ndjson/ndjsonMap.ts +2 -2
  156. package/src/stream/ndjson/ndjsonStreamForEach.ts +2 -2
  157. package/src/stream/ndjson/transformJsonParse.ts +1 -1
  158. package/src/stream/ndjson/transformToNDJson.ts +1 -1
  159. package/src/stream/pipeline/pipeline.ts +1 -1
  160. package/src/stream/progressLogger.ts +3 -3
  161. package/src/stream/readable/readableCreate.ts +1 -1
  162. package/src/stream/readable/readableForEach.ts +4 -4
  163. package/src/stream/readable/readableFromArray.ts +1 -1
  164. package/src/stream/readable/readableToArray.ts +1 -1
  165. package/src/stream/sizeStack.ts +2 -2
  166. package/src/stream/transform/transformChunk.ts +1 -1
  167. package/src/stream/transform/transformFilter.ts +3 -3
  168. package/src/stream/transform/transformLimit.ts +3 -3
  169. package/src/stream/transform/transformLogProgress.ts +3 -3
  170. package/src/stream/transform/transformMap.ts +5 -5
  171. package/src/stream/transform/transformMapSimple.ts +1 -1
  172. package/src/stream/transform/transformMapSync.ts +5 -5
  173. package/src/stream/transform/transformNoOp.ts +1 -1
  174. package/src/stream/transform/transformOffset.ts +2 -2
  175. package/src/stream/transform/transformSplit.ts +1 -1
  176. package/src/stream/transform/transformTap.ts +1 -1
  177. package/src/stream/transform/transformTee.ts +3 -3
  178. package/src/stream/transform/transformThrottle.ts +1 -1
  179. package/src/stream/transform/transformToArray.ts +1 -1
  180. package/src/stream/transform/worker/baseWorkerClass.ts +1 -1
  181. package/src/stream/transform/worker/transformMultiThreaded.ts +8 -3
  182. package/src/stream/transform/worker/workerClassProxy.js +6 -4
  183. package/src/stream/writable/writableForEach.ts +3 -3
  184. package/src/stream/writable/writableFork.ts +3 -3
  185. package/src/stream/writable/writableLimit.ts +1 -1
  186. package/src/stream/writable/writablePushToArray.ts +1 -1
  187. package/src/stream/writable/writableVoid.ts +1 -1
  188. package/src/util/buildInfo.util.ts +2 -2
  189. package/src/util/exec2.ts +1 -1
  190. package/src/util/git2.ts +2 -2
  191. package/src/validation/ajv/ajv.util.ts +4 -4
  192. package/src/validation/ajv/ajvSchema.ts +4 -5
  193. package/src/validation/ajv/getAjv.ts +7 -3
  194. package/src/validation/joi/joi.extensions.ts +4 -4
  195. package/src/validation/joi/joi.shared.schemas.ts +3 -3
  196. package/src/validation/joi/joi.validation.util.ts +2 -2
  197. package/src/yargs.util.ts +1 -0
@@ -1,5 +1,5 @@
1
1
  import { _hb, _ms } from '@naturalcycles/js-lib'
2
- import { boldWhite, dimWhite } from '../../colors/colors'
2
+ import { boldWhite, dimWhite } from '../../colors/colors.js'
3
3
 
4
4
  export class NDJsonStats {
5
5
  static create(o: Partial<NDJsonStats> = {}): NDJsonStats {
@@ -1,7 +1,7 @@
1
1
  import type { AbortableAsyncMapper } from '@naturalcycles/js-lib'
2
2
  import { ErrorMode } from '@naturalcycles/js-lib'
3
- import type { TransformLogProgressOptions, TransformMapOptions } from '../..'
4
- import { _pipeline, fs2, transformLimit, transformLogProgress, transformMap } from '../..'
3
+ import type { TransformLogProgressOptions, TransformMapOptions } from '../../index.js'
4
+ import { _pipeline, fs2, transformLimit, transformLogProgress, transformMap } from '../../index.js'
5
5
 
6
6
  export interface NDJSONMapOptions<IN = any, OUT = IN>
7
7
  extends TransformMapOptions<IN, OUT>,
@@ -1,7 +1,7 @@
1
1
  import type { AbortableAsyncMapper } from '@naturalcycles/js-lib'
2
2
  import { ErrorMode } from '@naturalcycles/js-lib'
3
- import type { TransformLogProgressOptions, TransformMapOptions } from '../..'
4
- import { _pipeline, fs2, transformLogProgress, transformMap, writableVoid } from '../..'
3
+ import type { TransformLogProgressOptions, TransformMapOptions } from '../../index.js'
4
+ import { _pipeline, fs2, transformLogProgress, transformMap, writableVoid } from '../../index.js'
5
5
 
6
6
  export interface NDJSONStreamForEachOptions<IN = any>
7
7
  extends TransformMapOptions<IN, void>,
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'node:stream'
2
2
  import type { Reviver } from '@naturalcycles/js-lib'
3
- import type { TransformTyped } from '../stream.model'
3
+ import type { TransformTyped } from '../stream.model.js'
4
4
 
5
5
  export interface TransformJsonParseOptions {
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import { Transform } from 'node:stream'
2
2
  import { _sortObjectDeep } from '@naturalcycles/js-lib'
3
- import type { TransformTyped } from '../stream.model'
3
+ import type { TransformTyped } from '../stream.model.js'
4
4
 
5
5
  export interface TransformToNDJsonOptions {
6
6
  /**
@@ -3,7 +3,7 @@ import { Transform } from 'node:stream'
3
3
  import { pipeline } from 'node:stream/promises'
4
4
  import type { AnyFunction, DeferredPromise } from '@naturalcycles/js-lib'
5
5
  import { _last, pDefer } from '@naturalcycles/js-lib'
6
- import { writablePushToArray } from '../writable/writablePushToArray'
6
+ import { writablePushToArray } from '../writable/writablePushToArray.js'
7
7
 
8
8
  type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream
9
9
 
@@ -2,9 +2,9 @@ import type { InspectOptions } from 'node:util'
2
2
  import { inspect } from 'node:util'
3
3
  import type { AnyObject, CommonLogger, UnixTimestampMillis } from '@naturalcycles/js-lib'
4
4
  import { _mb, _since, localTime, SimpleMovingAverage } from '@naturalcycles/js-lib'
5
- import { boldWhite, dimGrey, hasColors, white, yellow } from '../colors/colors'
6
- import { SizeStack } from './sizeStack'
7
- import type { ReadableMapper } from './stream.model'
5
+ import { boldWhite, dimGrey, hasColors, white, yellow } from '../colors/colors.js'
6
+ import { SizeStack } from './sizeStack.js'
7
+ import type { ReadableMapper } from './stream.model.js'
8
8
 
9
9
  export interface ProgressLoggerCfg<T = any> {
10
10
  /**
@@ -1,6 +1,6 @@
1
1
  import type { ReadableOptions } from 'node:stream'
2
2
  import { Readable } from 'node:stream'
3
- import type { ReadableTyped } from '../stream.model'
3
+ import type { ReadableTyped } from '../stream.model.js'
4
4
 
5
5
  /**
6
6
  * Convenience function to create a Readable that can be pushed into (similar to RxJS Subject).
@@ -1,9 +1,9 @@
1
1
  import type { AbortableAsyncMapper, Mapper } from '@naturalcycles/js-lib'
2
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'
3
+ import type { ReadableTyped } from '../../index.js'
4
+ import { _pipeline } from '../../index.js'
5
+ import type { TransformMapOptions } from '../transform/transformMap.js'
6
+ import { transformMap } from '../transform/transformMap.js'
7
7
 
8
8
  /**
9
9
  * Convenience function to do `.forEach` over a Readable.
@@ -2,7 +2,7 @@ import type { ReadableOptions } from 'node:stream'
2
2
  import { Readable } from 'node:stream'
3
3
  import type { AbortableAsyncMapper } from '@naturalcycles/js-lib'
4
4
  import { _passthroughMapper } from '@naturalcycles/js-lib'
5
- import type { ReadableTyped } from '../stream.model'
5
+ import type { ReadableTyped } from '../stream.model.js'
6
6
 
7
7
  /**
8
8
  * Create Readable from Array.
@@ -1,4 +1,4 @@
1
- import type { ReadableTyped } from '../stream.model'
1
+ import type { ReadableTyped } from '../stream.model.js'
2
2
 
3
3
  /**
4
4
  * Convenience function to read the whole Readable stream into Array (in-memory)
@@ -1,7 +1,7 @@
1
1
  import type { CommonLogger } from '@naturalcycles/js-lib'
2
2
  import { _hb, NumberStack } from '@naturalcycles/js-lib'
3
- import { yellow } from '../colors/colors'
4
- import { gzipBuffer } from '../util/zip.util'
3
+ import { yellow } from '../colors/colors.js'
4
+ import { gzipBuffer } from '../util/zip.util.js'
5
5
 
6
6
  export class SizeStack extends NumberStack {
7
7
  constructor(
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import type { TransformOptions, TransformTyped } from '../stream.model'
2
+ import type { TransformOptions, TransformTyped } from '../stream.model.js'
3
3
 
4
4
  export interface TransformChunkOptions extends TransformOptions {
5
5
  /**
@@ -1,8 +1,8 @@
1
1
  import { Transform } from 'node:stream'
2
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'
3
+ import type { TransformOptions, TransformTyped } from '../stream.model.js'
4
+ import type { TransformMapOptions } from './transformMap.js'
5
+ import { transformMap } from './transformMap.js'
6
6
 
7
7
  /**
8
8
  * Just a convenience wrapper around `transformMap` that has built-in predicate filtering support.
@@ -1,8 +1,8 @@
1
1
  import type { Readable } from 'node:stream'
2
2
  import type { CommonLogger } from '@naturalcycles/js-lib'
3
- import { AbortableTransform, transformNoOp } from '../../index'
4
- import type { TransformOptions, TransformTyped } from '../stream.model'
5
- import { pipelineClose } from '../stream.util'
3
+ import { AbortableTransform, transformNoOp } from '../../index.js'
4
+ import type { TransformOptions, TransformTyped } from '../stream.model.js'
5
+ import { pipelineClose } from '../stream.util.js'
6
6
 
7
7
  export interface TransformLimitOptions extends TransformOptions {
8
8
  /**
@@ -1,7 +1,7 @@
1
1
  import { Transform } from 'node:stream'
2
- import type { ProgressLoggerCfg } from '../progressLogger'
3
- import { progressLogger } from '../progressLogger'
4
- import type { TransformOptions, TransformTyped } from '../stream.model'
2
+ import type { ProgressLoggerCfg } from '../progressLogger.js'
3
+ import { progressLogger } from '../progressLogger.js'
4
+ import type { TransformOptions, TransformTyped } from '../stream.model.js'
5
5
 
6
6
  export interface TransformLogProgressOptions<IN = any>
7
7
  extends ProgressLoggerCfg<IN>,
@@ -16,11 +16,11 @@ import {
16
16
  pFilter,
17
17
  SKIP,
18
18
  } from '@naturalcycles/js-lib'
19
- import through2Concurrent = require('through2-concurrent')
20
- import { yellow } from '../../colors/colors'
21
- import type { AbortableTransform } from '../pipeline/pipeline'
22
- import type { TransformTyped } from '../stream.model'
23
- import { pipelineClose } from '../stream.util'
19
+ import through2Concurrent from 'through2-concurrent'
20
+ import { yellow } from '../../colors/colors.js'
21
+ import type { AbortableTransform } from '../pipeline/pipeline.js'
22
+ import type { TransformTyped } from '../stream.model.js'
23
+ import { pipelineClose } from '../stream.util.js'
24
24
 
25
25
  export interface TransformMapOptions<IN = any, OUT = IN> {
26
26
  /**
@@ -1,7 +1,7 @@
1
1
  import { Transform } from 'node:stream'
2
2
  import type { CommonLogger, Mapper } from '@naturalcycles/js-lib'
3
3
  import { ErrorMode } from '@naturalcycles/js-lib'
4
- import type { TransformTyped } from '../stream.model'
4
+ import type { TransformTyped } from '../stream.model.js'
5
5
 
6
6
  export interface TransformMapSimpleOptions {
7
7
  /**
@@ -1,10 +1,10 @@
1
1
  import type { CommonLogger, Mapper, Predicate, UnixTimestampMillis } from '@naturalcycles/js-lib'
2
2
  import { _anyToError, END, ErrorMode, SKIP } from '@naturalcycles/js-lib'
3
- import { yellow } from '../../colors/colors'
4
- import { AbortableTransform } from '../pipeline/pipeline'
5
- import type { TransformTyped } from '../stream.model'
6
- import { pipelineClose } from '../stream.util'
7
- import type { TransformMapStats } from './transformMap'
3
+ import { yellow } from '../../colors/colors.js'
4
+ import { AbortableTransform } from '../pipeline/pipeline.js'
5
+ import type { TransformTyped } from '../stream.model.js'
6
+ import { pipelineClose } from '../stream.util.js'
7
+ import type { TransformMapStats } from './transformMap.js'
8
8
 
9
9
  export interface TransformMapSyncOptions<IN = any, OUT = IN> {
10
10
  /**
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import type { TransformTyped } from '../stream.model'
2
+ import type { TransformTyped } from '../stream.model.js'
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
- import { transformNoOp } from '../../index'
3
- import type { TransformOptions, TransformTyped } from '../stream.model'
2
+ import { transformNoOp } from '../../index.js'
3
+ import type { TransformOptions, TransformTyped } from '../stream.model.js'
4
4
 
5
5
  export interface TransformOffsetOptions extends TransformOptions {
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import type { TransformTyped } from '../stream.model'
2
+ import type { TransformTyped } from '../stream.model.js'
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
2
  import type { AsyncMapper, CommonLogger } from '@naturalcycles/js-lib'
3
- import type { TransformOptions, TransformTyped } from '../stream.model'
3
+ import type { TransformOptions, TransformTyped } from '../stream.model.js'
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
- import { _pipeline } from '../pipeline/pipeline'
3
- import { readableCreate } from '../readable/readableCreate'
4
- import type { TransformTyped } from '../stream.model'
2
+ import { _pipeline } from '../pipeline/pipeline.js'
3
+ import { readableCreate } from '../readable/readableCreate.js'
4
+ import type { TransformTyped } from '../stream.model.js'
5
5
 
6
6
  type AnyStream = NodeJS.WritableStream | NodeJS.ReadWriteStream
7
7
 
@@ -6,7 +6,7 @@ import type {
6
6
  UnixTimestampMillis,
7
7
  } from '@naturalcycles/js-lib'
8
8
  import { _ms, _since, localTime, pDefer } from '@naturalcycles/js-lib'
9
- import type { TransformTyped } from '../stream.model'
9
+ import type { TransformTyped } from '../stream.model.js'
10
10
 
11
11
  export interface TransformThrottleOptions {
12
12
  /**
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import type { TransformOptions, TransformTyped } from '../stream.model'
2
+ import type { TransformOptions, TransformTyped } from '../stream.model.js'
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 type { BaseWorkerData } from './transformMultiThreaded.model'
1
+ import type { BaseWorkerData } from './transformMultiThreaded.model.js'
2
2
 
3
3
  export interface WorkerClassInterface<
4
4
  IN,
@@ -1,9 +1,14 @@
1
+ import { dirname } from 'node:path'
2
+ import { fileURLToPath } from 'node:url'
1
3
  import { Worker } from 'node:worker_threads'
2
4
  import type { AnyObject, DeferredPromise } from '@naturalcycles/js-lib'
3
5
  import { _range, pDefer } from '@naturalcycles/js-lib'
4
- import through2Concurrent = require('through2-concurrent')
5
- import type { TransformTyped } from '../../stream.model'
6
- import type { WorkerInput, WorkerOutput } from './transformMultiThreaded.model'
6
+ import through2Concurrent from 'through2-concurrent'
7
+ import type { TransformTyped } from '../../stream.model.js'
8
+ import type { WorkerInput, WorkerOutput } from './transformMultiThreaded.model.js'
9
+
10
+ const __filename = fileURLToPath(import.meta.url)
11
+ const __dirname = dirname(__filename)
7
12
 
8
13
  export interface TransformMultiThreadedOptions {
9
14
  /**
@@ -1,6 +1,6 @@
1
1
  const started = Date.now()
2
- const { workerData, parentPort } = require('node:worker_threads')
3
- const { inspect } = require('node:util')
2
+ import { workerData, parentPort } from 'node:worker_threads'
3
+ import { inspect } from 'node:util'
4
4
  const { workerFile, workerIndex, logEvery = 1000, metric = 'worker' } = workerData || {}
5
5
 
6
6
  if (!workerFile) {
@@ -12,11 +12,13 @@ if (!workerFile) {
12
12
  try {
13
13
  // require('esbuild-register') // alternative
14
14
  // require('ts-node/register/transpile-only')
15
- require('tsx/cjs/api').register() // https://tsx.is/dev-api/register-cjs
15
+ // require('tsx/cjs/api').register() // https://tsx.is/dev-api/register-cjs
16
+ const { register } = await import('tsx/esm/api')
17
+ register() // https://tsx.is/dev-api/register-esm
16
18
  // require('tsconfig-paths/register')
17
19
  } catch {} // require if exists
18
20
 
19
- const { WorkerClass } = require(workerFile)
21
+ const { WorkerClass } = await import(workerFile)
20
22
  const worker = new WorkerClass(workerData)
21
23
 
22
24
  console.log(`${metric}#${workerIndex} loaded in ${Date.now() - started} ms`)
@@ -1,8 +1,8 @@
1
1
  import type { AsyncMapper, Mapper } from '@naturalcycles/js-lib'
2
2
  import { _passNothingPredicate } from '@naturalcycles/js-lib'
3
- import type { TransformMapOptions } from '../..'
4
- import { transformMap, transformMapSync } from '../..'
5
- import type { WritableTyped } from '../stream.model'
3
+ import type { TransformMapOptions } from '../../index.js'
4
+ import { transformMap, transformMapSync } from '../../index.js'
5
+ import type { WritableTyped } from '../stream.model.js'
6
6
 
7
7
  /**
8
8
  * Just an alias to transformMap that declares OUT as void.
@@ -1,7 +1,7 @@
1
1
  import { Writable } from 'node:stream'
2
- import type { ReadableTyped } from '../..'
3
- import { _pipeline, readableCreate } from '../..'
4
- import type { TransformOptions, WritableTyped } from '../stream.model'
2
+ import type { ReadableTyped } from '../../index.js'
3
+ import { _pipeline, readableCreate } from '../../index.js'
4
+ import type { TransformOptions, WritableTyped } from '../stream.model.js'
5
5
 
6
6
  /**
7
7
  * Allows "forking" a stream inside pipeline into a number of pipeline chains (2 or more).
@@ -1,6 +1,6 @@
1
1
  import type { Readable } from 'node:stream'
2
2
  import { Writable } from 'node:stream'
3
- import type { WritableTyped } from '../stream.model'
3
+ import type { WritableTyped } from '../stream.model.js'
4
4
 
5
5
  /**
6
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 type { TransformOptions, WritableTyped } from '../stream.model'
2
+ import type { TransformOptions, WritableTyped } from '../stream.model.js'
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
2
  import type { DeferredPromise } from '@naturalcycles/js-lib'
3
- import type { TransformOptions } from '../stream.model'
3
+ import type { TransformOptions } from '../stream.model.js'
4
4
 
5
5
  export interface WritableVoidOptions extends TransformOptions {
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import type { AnyObject, BuildInfo, UnixTimestamp } from '@naturalcycles/js-lib'
2
2
  import { _filterUndefinedValues, localTime } from '@naturalcycles/js-lib'
3
- import { fs2 } from '../fs/fs2'
4
- import { git2 } from './git2'
3
+ import { fs2 } from '../fs/fs2.js'
4
+ import { git2 } from './git2.js'
5
5
 
6
6
  export interface GenerateBuildInfoOptions {
7
7
  /**
package/src/util/exec2.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { execSync, spawn, spawnSync } from 'node:child_process'
2
2
  import type { AnyObject, NumberOfMilliseconds, UnixTimestampMillis } from '@naturalcycles/js-lib'
3
3
  import { _since, AppError } from '@naturalcycles/js-lib'
4
- import { dimGrey, dimRed, hasColors, white } from '../colors/colors'
4
+ import { dimGrey, dimRed, hasColors, white } from '../colors/colors.js'
5
5
 
6
6
  /**
7
7
  * Set of utility functions to work with Spawn / Exec.
package/src/util/git2.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { execSync } from 'node:child_process'
2
2
  import { basename } from 'node:path'
3
3
  import type { UnixTimestamp } from '@naturalcycles/js-lib'
4
- import { grey } from '../colors/colors'
5
- import { exec2 } from './exec2'
4
+ import { grey } from '../colors/colors.js'
5
+ import { exec2 } from './exec2.js'
6
6
 
7
7
  /**
8
8
  * Set of utility functions to work with git.
@@ -1,8 +1,8 @@
1
1
  import type { JsonSchema } from '@naturalcycles/js-lib'
2
- import type { FastGlobOptions } from '../..'
3
- import { fastGlob, fs2 } from '../..'
4
- import type { AjvSchemaCfg } from './ajvSchema'
5
- import { AjvSchema } from './ajvSchema'
2
+ import type { FastGlobOptions } from '../../index.js'
3
+ import { fastGlob, fs2 } from '../../index.js'
4
+ import type { AjvSchemaCfg } from './ajvSchema.js'
5
+ import { AjvSchema } from './ajvSchema.js'
6
6
 
7
7
  /**
8
8
  * Does fs.readFileSync + JSON.parse for ALL files matching the passed `glob` pattern.
@@ -5,11 +5,10 @@ import {
5
5
  _substringBefore,
6
6
  JsonSchemaAnyBuilder,
7
7
  } from '@naturalcycles/js-lib'
8
- import type { ValidateFunction } from 'ajv'
9
- import type Ajv from 'ajv'
10
- import { _inspect, fs2, requireFileToExist } from '../../index'
11
- import { AjvValidationError } from './ajvValidationError'
12
- import { getAjv } from './getAjv'
8
+ import type { Ajv, ValidateFunction } from 'ajv'
9
+ import { _inspect, fs2, requireFileToExist } from '../../index.js'
10
+ import { AjvValidationError } from './ajvValidationError.js'
11
+ import { getAjv } from './getAjv.js'
13
12
 
14
13
  export interface AjvValidationOptions {
15
14
  objectName?: string
@@ -1,5 +1,7 @@
1
1
  import type { Options } from 'ajv'
2
- import Ajv from 'ajv'
2
+ import { Ajv } from 'ajv'
3
+ import ajvFormats from 'ajv-formats'
4
+ import ajvKeywords from 'ajv-keywords'
3
5
 
4
6
  const AJV_OPTIONS: Options = {
5
7
  removeAdditional: true,
@@ -27,10 +29,12 @@ export function getAjv(opt?: Options): Ajv {
27
29
 
28
30
  // Adds ajv "formats"
29
31
  // https://ajv.js.org/guide/formats.html
30
- require('ajv-formats')(ajv)
32
+ // @ts-expect-error types are wrong
33
+ ajvFormats(ajv)
31
34
 
32
35
  // https://ajv.js.org/packages/ajv-keywords.html
33
- require('ajv-keywords')(ajv, [
36
+ // @ts-expect-error types are wrong
37
+ ajvKeywords(ajv, [
34
38
  'transform', // trim, toLowerCase, etc.
35
39
  'uniqueItemProperties',
36
40
  'instanceof',
@@ -1,8 +1,8 @@
1
1
  import JoiLib from 'joi'
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'
2
+ import type { NumberSchema } from './number.extensions.js'
3
+ import { numberExtensions } from './number.extensions.js'
4
+ import type { StringSchema } from './string.extensions.js'
5
+ import { stringExtensions } from './string.extensions.js'
6
6
 
7
7
  export interface ExtendedJoi extends JoiLib.Root {
8
8
  // eslint-disable-next-line id-blacklist
@@ -14,9 +14,9 @@ import {
14
14
  _stringEnumValues,
15
15
  } from '@naturalcycles/js-lib'
16
16
  import type { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi'
17
- import { Joi } from './joi.extensions'
18
- import type { NumberSchema } from './number.extensions'
19
- import type { StringSchema } from './string.extensions'
17
+ import { Joi } from './joi.extensions.js'
18
+ import type { NumberSchema } from './number.extensions.js'
19
+ import type { StringSchema } from './string.extensions.js'
20
20
 
21
21
  export const booleanSchema = Joi.boolean()
22
22
  export const booleanDefaultToFalseSchema = Joi.boolean().default(false)
@@ -8,8 +8,8 @@
8
8
 
9
9
  import { _hb, _isObject, _truncateMiddle } from '@naturalcycles/js-lib'
10
10
  import type { AnySchema, ValidationError, ValidationOptions } from 'joi'
11
- import type { JoiValidationErrorData } from './joi.validation.error'
12
- import { JoiValidationError } from './joi.validation.error'
11
+ import type { JoiValidationErrorData } from './joi.validation.error.js'
12
+ import { JoiValidationError } from './joi.validation.error.js'
13
13
 
14
14
  // todo: consider replacing with Tuple of [error, value]
15
15
  export interface JoiValidationResult<T = any> {
package/src/yargs.util.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import yargs from 'yargs'
2
+ // @ts-expect-error yargs types disagree with runtime
2
3
  import { hideBin } from 'yargs/helpers'
3
4
 
4
5
  /**