@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.
- package/dist/bin/generate-build-info.js +15 -18
- package/dist/bin/json2env.js +6 -9
- package/dist/bin/kpy.js +6 -9
- package/dist/bin/secrets-decrypt.d.ts +1 -1
- package/dist/bin/secrets-decrypt.js +9 -12
- package/dist/bin/secrets-encrypt.d.ts +1 -1
- package/dist/bin/secrets-encrypt.js +9 -12
- package/dist/bin/secrets-gen-key.js +8 -11
- package/dist/bin/slack-this.js +6 -9
- package/dist/buffer/buffer.util.js +1 -4
- package/dist/colors/colors.d.ts +26 -27
- package/dist/colors/colors.js +29 -33
- package/dist/csv/csvReader.js +4 -8
- package/dist/csv/csvWriter.js +7 -12
- package/dist/csv/transformToCSV.d.ts +2 -2
- package/dist/csv/transformToCSV.js +5 -8
- package/dist/diff/tableDiff.js +4 -7
- package/dist/fs/fs2.d.ts +1 -1
- package/dist/fs/fs2.js +88 -94
- package/dist/fs/json2env.js +18 -28
- package/dist/fs/kpy.js +28 -33
- package/dist/index.d.ts +71 -71
- package/dist/index.js +73 -78
- package/dist/infra/process.util.js +23 -28
- package/dist/jwt/jwt.service.js +17 -21
- package/dist/log/log.util.js +4 -7
- package/dist/script/runScript.js +11 -15
- package/dist/secret/secrets-decrypt.util.js +18 -22
- package/dist/secret/secrets-encrypt.util.js +17 -21
- package/dist/security/crypto.util.js +24 -34
- package/dist/security/hash.util.js +19 -37
- package/dist/security/id.util.js +11 -18
- package/dist/security/nanoid.js +15 -20
- package/dist/security/secret.util.js +20 -30
- package/dist/slack/slack.service.d.ts +1 -1
- package/dist/slack/slack.service.js +13 -16
- package/dist/slack/slack.service.model.d.ts +1 -1
- package/dist/slack/slack.service.model.js +1 -2
- package/dist/stream/ndjson/ndjson.model.js +10 -16
- package/dist/stream/ndjson/ndjsonMap.d.ts +1 -1
- package/dist/stream/ndjson/ndjsonMap.js +11 -14
- package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +1 -1
- package/dist/stream/ndjson/ndjsonStreamForEach.js +9 -12
- package/dist/stream/ndjson/transformJsonParse.d.ts +1 -1
- package/dist/stream/ndjson/transformJsonParse.js +4 -9
- package/dist/stream/ndjson/transformToNDJson.d.ts +1 -1
- package/dist/stream/ndjson/transformToNDJson.js +5 -8
- package/dist/stream/pipeline/pipeline.js +13 -17
- package/dist/stream/progressLogger.d.ts +1 -1
- package/dist/stream/progressLogger.js +32 -28
- package/dist/stream/readable/readableCreate.d.ts +1 -1
- package/dist/stream/readable/readableCreate.js +5 -9
- package/dist/stream/readable/readableForEach.d.ts +2 -2
- package/dist/stream/readable/readableForEach.js +7 -11
- package/dist/stream/readable/readableFromArray.d.ts +1 -1
- package/dist/stream/readable/readableFromArray.js +4 -7
- package/dist/stream/readable/readableToArray.d.ts +1 -1
- package/dist/stream/readable/readableToArray.js +1 -4
- package/dist/stream/sizeStack.js +9 -12
- package/dist/stream/stream.model.js +1 -2
- package/dist/stream/stream.util.js +1 -4
- package/dist/stream/transform/transformChunk.d.ts +1 -1
- package/dist/stream/transform/transformChunk.js +3 -6
- package/dist/stream/transform/transformFilter.d.ts +2 -2
- package/dist/stream/transform/transformFilter.js +6 -10
- package/dist/stream/transform/transformLimit.d.ts +2 -2
- package/dist/stream/transform/transformLimit.js +6 -11
- package/dist/stream/transform/transformLogProgress.d.ts +2 -2
- package/dist/stream/transform/transformLogProgress.js +5 -8
- package/dist/stream/transform/transformMap.d.ts +1 -1
- package/dist/stream/transform/transformMap.js +18 -22
- package/dist/stream/transform/transformMapSimple.d.ts +1 -1
- package/dist/stream/transform/transformMapSimple.js +6 -9
- package/dist/stream/transform/transformMapSync.d.ts +3 -3
- package/dist/stream/transform/transformMapSync.js +14 -19
- package/dist/stream/transform/transformNoOp.d.ts +1 -1
- package/dist/stream/transform/transformNoOp.js +3 -6
- package/dist/stream/transform/transformOffset.d.ts +1 -1
- package/dist/stream/transform/transformOffset.js +5 -8
- package/dist/stream/transform/transformSplit.d.ts +1 -1
- package/dist/stream/transform/transformSplit.js +5 -9
- package/dist/stream/transform/transformTap.d.ts +1 -1
- package/dist/stream/transform/transformTap.js +3 -6
- package/dist/stream/transform/transformTee.d.ts +1 -1
- package/dist/stream/transform/transformTee.js +7 -10
- package/dist/stream/transform/transformThrottle.d.ts +1 -1
- package/dist/stream/transform/transformThrottle.js +9 -12
- package/dist/stream/transform/transformToArray.d.ts +1 -1
- package/dist/stream/transform/transformToArray.js +3 -6
- package/dist/stream/transform/worker/baseWorkerClass.d.ts +1 -1
- package/dist/stream/transform/worker/baseWorkerClass.js +2 -5
- package/dist/stream/transform/worker/transformMultiThreaded.d.ts +1 -1
- package/dist/stream/transform/worker/transformMultiThreaded.js +12 -11
- package/dist/stream/transform/worker/transformMultiThreaded.model.js +1 -2
- package/dist/stream/transform/worker/workerClassProxy.js +6 -4
- package/dist/stream/writable/writableForEach.d.ts +2 -2
- package/dist/stream/writable/writableForEach.js +6 -10
- package/dist/stream/writable/writableFork.d.ts +1 -1
- package/dist/stream/writable/writableFork.js +6 -9
- package/dist/stream/writable/writableLimit.d.ts +1 -1
- package/dist/stream/writable/writableLimit.js +3 -6
- package/dist/stream/writable/writablePushToArray.d.ts +1 -1
- package/dist/stream/writable/writablePushToArray.js +3 -6
- package/dist/stream/writable/writableVoid.d.ts +1 -1
- package/dist/stream/writable/writableVoid.js +3 -6
- package/dist/string/inspect.js +8 -13
- package/dist/util/buildInfo.util.js +12 -15
- package/dist/util/env.util.js +5 -9
- package/dist/util/exec2.js +17 -21
- package/dist/util/git2.js +17 -20
- package/dist/util/lruMemoCache.js +4 -7
- package/dist/util/zip.util.js +14 -25
- package/dist/validation/ajv/ajv.util.d.ts +3 -3
- package/dist/validation/ajv/ajv.util.js +6 -10
- package/dist/validation/ajv/ajvSchema.d.ts +2 -2
- package/dist/validation/ajv/ajvSchema.js +17 -18
- package/dist/validation/ajv/ajvValidationError.js +2 -6
- package/dist/validation/ajv/getAjv.d.ts +1 -1
- package/dist/validation/ajv/getAjv.js +9 -9
- package/dist/validation/joi/joi.extensions.d.ts +2 -2
- package/dist/validation/joi/joi.extensions.js +6 -10
- package/dist/validation/joi/joi.model.js +1 -2
- package/dist/validation/joi/joi.shared.schemas.d.ts +2 -2
- package/dist/validation/joi/joi.shared.schemas.js +61 -74
- package/dist/validation/joi/joi.validation.error.js +2 -6
- package/dist/validation/joi/joi.validation.util.d.ts +1 -1
- package/dist/validation/joi/joi.validation.util.js +10 -17
- package/dist/validation/joi/number.extensions.js +1 -4
- package/dist/validation/joi/string.extensions.js +4 -7
- package/dist/yargs.util.js +5 -8
- package/package.json +5 -4
- package/src/bin/generate-build-info.ts +3 -3
- package/src/bin/json2env.ts +2 -2
- package/src/bin/kpy.ts +2 -2
- package/src/bin/secrets-decrypt.ts +7 -8
- package/src/bin/secrets-encrypt.ts +7 -8
- package/src/bin/secrets-gen-key.ts +2 -2
- package/src/bin/slack-this.ts +2 -2
- package/src/csv/transformToCSV.ts +3 -3
- package/src/fs/fs2.ts +4 -4
- package/src/fs/json2env.ts +2 -2
- package/src/fs/kpy.ts +2 -2
- package/src/index.ts +71 -71
- package/src/jwt/jwt.service.ts +2 -2
- package/src/log/log.util.ts +1 -1
- package/src/script/runScript.ts +4 -3
- package/src/secret/secrets-decrypt.util.ts +3 -3
- package/src/secret/secrets-encrypt.util.ts +3 -3
- package/src/security/crypto.util.ts +1 -1
- package/src/security/id.util.ts +1 -1
- package/src/security/secret.util.ts +2 -2
- package/src/slack/slack.service.model.ts +1 -1
- package/src/slack/slack.service.ts +3 -3
- package/src/stream/ndjson/ndjson.model.ts +1 -1
- package/src/stream/ndjson/ndjsonMap.ts +2 -2
- package/src/stream/ndjson/ndjsonStreamForEach.ts +2 -2
- package/src/stream/ndjson/transformJsonParse.ts +1 -1
- package/src/stream/ndjson/transformToNDJson.ts +1 -1
- package/src/stream/pipeline/pipeline.ts +1 -1
- package/src/stream/progressLogger.ts +3 -3
- package/src/stream/readable/readableCreate.ts +1 -1
- package/src/stream/readable/readableForEach.ts +4 -4
- package/src/stream/readable/readableFromArray.ts +1 -1
- package/src/stream/readable/readableToArray.ts +1 -1
- package/src/stream/sizeStack.ts +2 -2
- package/src/stream/transform/transformChunk.ts +1 -1
- package/src/stream/transform/transformFilter.ts +3 -3
- package/src/stream/transform/transformLimit.ts +3 -3
- package/src/stream/transform/transformLogProgress.ts +3 -3
- package/src/stream/transform/transformMap.ts +5 -5
- package/src/stream/transform/transformMapSimple.ts +1 -1
- package/src/stream/transform/transformMapSync.ts +5 -5
- package/src/stream/transform/transformNoOp.ts +1 -1
- package/src/stream/transform/transformOffset.ts +2 -2
- package/src/stream/transform/transformSplit.ts +1 -1
- package/src/stream/transform/transformTap.ts +1 -1
- package/src/stream/transform/transformTee.ts +3 -3
- package/src/stream/transform/transformThrottle.ts +1 -1
- package/src/stream/transform/transformToArray.ts +1 -1
- package/src/stream/transform/worker/baseWorkerClass.ts +1 -1
- package/src/stream/transform/worker/transformMultiThreaded.ts +8 -3
- package/src/stream/transform/worker/workerClassProxy.js +6 -4
- package/src/stream/writable/writableForEach.ts +3 -3
- package/src/stream/writable/writableFork.ts +3 -3
- package/src/stream/writable/writableLimit.ts +1 -1
- package/src/stream/writable/writablePushToArray.ts +1 -1
- package/src/stream/writable/writableVoid.ts +1 -1
- package/src/util/buildInfo.util.ts +2 -2
- package/src/util/exec2.ts +1 -1
- package/src/util/git2.ts +2 -2
- package/src/validation/ajv/ajv.util.ts +4 -4
- package/src/validation/ajv/ajvSchema.ts +4 -5
- package/src/validation/ajv/getAjv.ts +7 -3
- package/src/validation/joi/joi.extensions.ts +4 -4
- package/src/validation/joi/joi.shared.schemas.ts +3 -3
- package/src/validation/joi/joi.validation.util.ts +2 -2
- package/src/yargs.util.ts +1 -0
|
@@ -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>,
|
|
@@ -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.
|
package/src/stream/sizeStack.ts
CHANGED
|
@@ -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,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
|
|
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,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,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,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
|
|
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
|
-
|
|
3
|
-
|
|
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 } =
|
|
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,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
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
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
|
-
|
|
32
|
+
// @ts-expect-error types are wrong
|
|
33
|
+
ajvFormats(ajv)
|
|
31
34
|
|
|
32
35
|
// https://ajv.js.org/packages/ajv-keywords.html
|
|
33
|
-
|
|
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> {
|