@naturalcycles/nodejs-lib 15.2.0 → 15.4.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/slack-this.js +1 -1
- package/dist/cache/lruMemoCache.d.ts +1 -1
- package/dist/csv/csvReader.d.ts +1 -1
- package/dist/csv/csvReader.js +1 -1
- package/dist/csv/csvWriter.d.ts +1 -1
- package/dist/csv/csvWriter.js +1 -1
- package/dist/csv/transformToCSV.d.ts +1 -1
- package/dist/diff/tableDiff.d.ts +1 -1
- package/dist/diff/tableDiff.js +1 -1
- package/dist/{exec2.d.ts → exec2/exec2.d.ts} +2 -2
- package/dist/{exec2.js → exec2/exec2.js} +4 -3
- package/dist/fs/fs2.js +1 -1
- package/dist/fs/json2env.d.ts +1 -1
- package/dist/fs/kpy.js +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/jwt/jwt.service.d.ts +2 -1
- package/dist/jwt/jwt.service.js +1 -1
- package/dist/log/log.util.d.ts +1 -1
- package/dist/log/log.util.js +1 -1
- package/dist/script/runScript.d.ts +2 -1
- package/dist/script/runScript.js +6 -5
- package/dist/secret/secrets-decrypt.util.js +1 -1
- package/dist/secret/secrets-encrypt.util.js +1 -1
- package/dist/security/crypto.util.d.ts +1 -1
- package/dist/security/crypto.util.js +1 -1
- package/dist/security/hash.util.d.ts +1 -1
- package/dist/security/secret.util.d.ts +1 -1
- package/dist/security/secret.util.js +2 -1
- package/dist/slack/index.d.ts +2 -0
- package/dist/slack/index.js +2 -0
- package/dist/slack/slack.service.d.ts +2 -1
- package/dist/slack/slack.service.js +5 -1
- package/dist/slack/slack.service.model.d.ts +3 -2
- package/dist/stream/ndjson/ndjson.model.js +2 -1
- package/dist/stream/ndjson/ndjsonMap.d.ts +1 -1
- package/dist/stream/ndjson/ndjsonMap.js +1 -1
- package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +3 -2
- package/dist/stream/ndjson/ndjsonStreamForEach.js +6 -3
- package/dist/stream/ndjson/transformJsonParse.d.ts +1 -1
- package/dist/stream/ndjson/transformToNDJson.js +1 -1
- package/dist/stream/pipeline/pipeline.d.ts +1 -1
- package/dist/stream/pipeline/pipeline.js +2 -1
- package/dist/stream/progressLogger.d.ts +2 -1
- package/dist/stream/progressLogger.js +3 -1
- package/dist/stream/readable/readableForEach.d.ts +2 -2
- package/dist/stream/readable/readableForEach.js +2 -2
- package/dist/stream/readable/readableFromArray.d.ts +1 -1
- package/dist/stream/readable/readableFromArray.js +1 -1
- package/dist/stream/sizeStack.d.ts +2 -2
- package/dist/stream/sizeStack.js +2 -1
- package/dist/stream/stream.model.d.ts +1 -1
- package/dist/stream/stream.util.d.ts +1 -1
- package/dist/stream/transform/transformFilter.d.ts +1 -1
- package/dist/stream/transform/transformLimit.d.ts +2 -2
- package/dist/stream/transform/transformLimit.js +2 -1
- package/dist/stream/transform/transformMap.d.ts +3 -2
- package/dist/stream/transform/transformMap.js +6 -1
- package/dist/stream/transform/transformMapSimple.d.ts +3 -2
- package/dist/stream/transform/transformMapSimple.js +1 -1
- package/dist/stream/transform/transformMapSync.d.ts +4 -2
- package/dist/stream/transform/transformMapSync.js +2 -1
- package/dist/stream/transform/transformOffset.js +1 -1
- package/dist/stream/transform/transformTap.d.ts +2 -1
- package/dist/stream/transform/transformThrottle.d.ts +1 -1
- package/dist/stream/transform/transformThrottle.js +2 -1
- package/dist/stream/transform/worker/transformMultiThreaded.d.ts +1 -1
- package/dist/stream/transform/worker/transformMultiThreaded.js +2 -1
- package/dist/stream/writable/writableForEach.d.ts +2 -2
- package/dist/stream/writable/writableForEach.js +3 -2
- package/dist/stream/writable/writableFork.js +2 -1
- package/dist/stream/writable/writableVoid.d.ts +1 -1
- package/dist/string/inspect.d.ts +1 -1
- package/dist/string/inspect.js +1 -1
- package/dist/util/buildInfo.util.d.ts +2 -1
- package/dist/util/buildInfo.util.js +2 -1
- package/dist/util/env.util.d.ts +1 -1
- package/dist/util/git2.d.ts +1 -1
- package/dist/util/git2.js +1 -1
- package/dist/validation/ajv/ajvSchema.d.ts +11 -9
- package/dist/validation/ajv/ajvSchema.js +32 -27
- package/dist/validation/ajv/ajvValidationError.d.ts +2 -2
- package/dist/validation/ajv/ajvValidationError.js +1 -1
- package/dist/validation/ajv/getAjv.d.ts +10 -1
- package/dist/validation/ajv/getAjv.js +11 -1
- package/dist/validation/ajv/index.d.ts +0 -1
- package/dist/validation/ajv/index.js +0 -1
- package/dist/validation/joi/joi.shared.schemas.d.ts +2 -2
- package/dist/validation/joi/joi.validation.error.d.ts +2 -2
- package/dist/validation/joi/joi.validation.error.js +1 -1
- package/dist/validation/joi/joi.validation.util.d.ts +2 -0
- package/dist/validation/joi/joi.validation.util.js +4 -1
- package/dist/validation/joi/string.extensions.d.ts +1 -1
- package/dist/validation/joi/string.extensions.js +1 -1
- package/package.json +5 -3
- package/src/bin/generate-build-info.ts +1 -1
- package/src/bin/slack-this.ts +1 -1
- package/src/cache/lruMemoCache.ts +1 -1
- package/src/csv/csvReader.ts +2 -2
- package/src/csv/csvWriter.ts +2 -2
- package/src/csv/transformToCSV.ts +1 -1
- package/src/diff/tableDiff.ts +2 -2
- package/src/{exec2.ts → exec2/exec2.ts} +9 -8
- package/src/fs/fs2.ts +1 -1
- package/src/fs/json2env.ts +1 -1
- package/src/fs/kpy.ts +2 -2
- package/src/index.ts +0 -3
- package/src/jwt/jwt.service.ts +3 -2
- package/src/log/log.util.ts +1 -1
- package/src/script/runScript.ts +8 -8
- package/src/secret/secrets-decrypt.util.ts +1 -1
- package/src/secret/secrets-encrypt.util.ts +1 -1
- package/src/security/crypto.util.ts +1 -2
- package/src/security/hash.util.ts +1 -1
- package/src/security/secret.util.ts +3 -2
- package/src/slack/index.ts +2 -0
- package/src/slack/slack.service.model.ts +3 -2
- package/src/slack/slack.service.ts +11 -4
- package/src/stream/ndjson/ndjson.model.ts +2 -1
- package/src/stream/ndjson/ndjsonMap.ts +2 -2
- package/src/stream/ndjson/ndjsonStreamForEach.ts +8 -6
- package/src/stream/ndjson/transformJsonParse.ts +1 -1
- package/src/stream/ndjson/transformToNDJson.ts +1 -1
- package/src/stream/pipeline/pipeline.ts +4 -2
- package/src/stream/progressLogger.ts +5 -2
- package/src/stream/readable/readableForEach.ts +4 -4
- package/src/stream/readable/readableFromArray.ts +2 -2
- package/src/stream/sizeStack.ts +3 -2
- package/src/stream/stream.model.ts +1 -1
- package/src/stream/stream.util.ts +1 -1
- package/src/stream/transform/transformFilter.ts +1 -1
- package/src/stream/transform/transformLimit.ts +3 -2
- package/src/stream/transform/transformMap.ts +12 -15
- package/src/stream/transform/transformMapSimple.ts +3 -2
- package/src/stream/transform/transformMapSync.ts +4 -7
- package/src/stream/transform/transformOffset.ts +1 -1
- package/src/stream/transform/transformTap.ts +2 -1
- package/src/stream/transform/transformThrottle.ts +4 -3
- package/src/stream/transform/worker/transformMultiThreaded.ts +4 -2
- package/src/stream/writable/writableForEach.ts +4 -4
- package/src/stream/writable/writableFork.ts +3 -3
- package/src/stream/writable/writableVoid.ts +1 -1
- package/src/string/inspect.ts +2 -2
- package/src/util/buildInfo.util.ts +4 -2
- package/src/util/env.util.ts +1 -1
- package/src/util/git2.ts +2 -2
- package/src/validation/ajv/ajvSchema.ts +47 -39
- package/src/validation/ajv/ajvValidationError.ts +2 -2
- package/src/validation/ajv/getAjv.ts +12 -1
- package/src/validation/ajv/index.ts +0 -1
- package/src/validation/joi/joi.shared.schemas.ts +7 -7
- package/src/validation/joi/joi.validation.error.ts +2 -2
- package/src/validation/joi/joi.validation.util.ts +4 -1
- package/src/validation/joi/string.extensions.ts +2 -2
- package/dist/validation/ajv/ajv.util.d.ts +0 -21
- package/dist/validation/ajv/ajv.util.js +0 -28
- package/src/validation/ajv/ajv.util.ts +0 -38
package/dist/bin/slack-this.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { SlackService } from '../index.js';
|
|
3
2
|
import { runScript } from '../script/runScript.js';
|
|
3
|
+
import { SlackService } from '../slack/index.js';
|
|
4
4
|
import { _yargs } from '../yargs/yargs.util.js';
|
|
5
5
|
runScript(async () => {
|
|
6
6
|
const { channel, msg, username, emoji, webhook: webhookUrl, } = _yargs().options({
|
package/dist/csv/csvReader.d.ts
CHANGED
package/dist/csv/csvReader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Inspired by: https://gist.github.com/Jezternz/c8e9fafc2c114e079829974e3764db75
|
|
2
|
-
import { _assert } from '@naturalcycles/js-lib';
|
|
2
|
+
import { _assert } from '@naturalcycles/js-lib/error';
|
|
3
3
|
// export class CSVReader {
|
|
4
4
|
// constructor (cfg: CSVReaderConfig) {
|
|
5
5
|
// this.cfg = {
|
package/dist/csv/csvWriter.d.ts
CHANGED
package/dist/csv/csvWriter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AnyObject } from '@naturalcycles/js-lib';
|
|
1
|
+
import type { AnyObject } from '@naturalcycles/js-lib/types';
|
|
2
2
|
import type { TransformTyped } from '../stream/stream.model.js';
|
|
3
3
|
import type { CSVWriterConfig } from './csvWriter.js';
|
|
4
4
|
export interface TransformToCSVOptions extends CSVWriterConfig {
|
package/dist/diff/tableDiff.d.ts
CHANGED
package/dist/diff/tableDiff.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AppError } from '@naturalcycles/js-lib/error';
|
|
2
|
+
import type { AnyObject, NumberOfMilliseconds } from '@naturalcycles/js-lib/types';
|
|
3
3
|
/**
|
|
4
4
|
* Set of utility functions to work with Spawn / Exec.
|
|
5
5
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { execSync, spawn, spawnSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { _since } from '@naturalcycles/js-lib/datetime';
|
|
3
|
+
import { AppError } from '@naturalcycles/js-lib/error';
|
|
4
|
+
import { _substringAfterLast } from '@naturalcycles/js-lib/string';
|
|
5
|
+
import { dimGrey, dimRed, hasColors, white } from '../colors/colors.js';
|
|
5
6
|
/**
|
|
6
7
|
* Set of utility functions to work with Spawn / Exec.
|
|
7
8
|
*
|
package/dist/fs/fs2.js
CHANGED
|
@@ -16,7 +16,7 @@ Credit to: fs-extra (https://github.com/jprichardson/node-fs-extra)
|
|
|
16
16
|
import fs from 'node:fs';
|
|
17
17
|
import fsp from 'node:fs/promises';
|
|
18
18
|
import path from 'node:path';
|
|
19
|
-
import { _jsonParse } from '@naturalcycles/js-lib';
|
|
19
|
+
import { _jsonParse } from '@naturalcycles/js-lib/string';
|
|
20
20
|
/**
|
|
21
21
|
* fs2 conveniently groups filesystem functions together.
|
|
22
22
|
* Supposed to be almost a drop-in replacement for these things together:
|
package/dist/fs/json2env.d.ts
CHANGED
package/dist/fs/kpy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { _since, localTime } from '@naturalcycles/js-lib';
|
|
2
|
+
import { _since, localTime } from '@naturalcycles/js-lib/datetime';
|
|
3
3
|
import { glob, globSync } from 'tinyglobby';
|
|
4
4
|
import { boldWhite, dimGrey, grey, yellow } from '../colors/colors.js';
|
|
5
5
|
import { fs2 } from './fs2.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,11 @@ export * from './buffer/buffer.util.js';
|
|
|
2
2
|
export * from './diff/tableDiff.js';
|
|
3
3
|
export * from './infra/process.util.js';
|
|
4
4
|
export * from './log/log.util.js';
|
|
5
|
-
export * from './script/runScript.js';
|
|
6
5
|
export * from './security/crypto.util.js';
|
|
7
6
|
export * from './security/hash.util.js';
|
|
8
7
|
export * from './security/id.util.js';
|
|
9
8
|
export * from './security/nanoid.js';
|
|
10
9
|
export * from './security/secret.util.js';
|
|
11
|
-
export * from './slack/slack.service.js';
|
|
12
|
-
export * from './slack/slack.service.model.js';
|
|
13
10
|
export * from './string/inspect.js';
|
|
14
11
|
export * from './util/buildInfo.util.js';
|
|
15
12
|
export * from './util/env.util.js';
|
package/dist/index.js
CHANGED
|
@@ -2,14 +2,11 @@ export * from './buffer/buffer.util.js';
|
|
|
2
2
|
export * from './diff/tableDiff.js';
|
|
3
3
|
export * from './infra/process.util.js';
|
|
4
4
|
export * from './log/log.util.js';
|
|
5
|
-
export * from './script/runScript.js';
|
|
6
5
|
export * from './security/crypto.util.js';
|
|
7
6
|
export * from './security/hash.util.js';
|
|
8
7
|
export * from './security/id.util.js';
|
|
9
8
|
export * from './security/nanoid.js';
|
|
10
9
|
export * from './security/secret.util.js';
|
|
11
|
-
export * from './slack/slack.service.js';
|
|
12
|
-
export * from './slack/slack.service.model.js';
|
|
13
10
|
export * from './string/inspect.js';
|
|
14
11
|
export * from './util/buildInfo.util.js';
|
|
15
12
|
export * from './util/env.util.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ErrorData } from '@naturalcycles/js-lib/error';
|
|
2
|
+
import type { AnyObject, JWTString } from '@naturalcycles/js-lib/types';
|
|
2
3
|
import type { AnySchema } from 'joi';
|
|
3
4
|
import type { Algorithm, JwtHeader, SignOptions, VerifyOptions } from 'jsonwebtoken';
|
|
4
5
|
import jsonwebtoken from 'jsonwebtoken';
|
package/dist/jwt/jwt.service.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _assert, _errorDataAppend } from '@naturalcycles/js-lib';
|
|
1
|
+
import { _assert, _errorDataAppend } from '@naturalcycles/js-lib/error';
|
|
2
2
|
import jsonwebtoken from 'jsonwebtoken';
|
|
3
3
|
import { anyObjectSchema } from '../validation/joi/joi.shared.schemas.js';
|
|
4
4
|
import { validate } from '../validation/joi/joi.validation.util.js';
|
package/dist/log/log.util.d.ts
CHANGED
package/dist/log/log.util.js
CHANGED
package/dist/script/runScript.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
1
2
|
import os from 'node:os';
|
|
2
|
-
import { pDelay
|
|
3
|
+
import { pDelay } from '@naturalcycles/js-lib/promise';
|
|
4
|
+
import { setGlobalStringifyFunction } from '@naturalcycles/js-lib/string';
|
|
5
|
+
import { dimGrey } from '../colors/colors.js';
|
|
3
6
|
import { inspectStringifyFn } from '../string/inspect.js';
|
|
4
7
|
const { DEBUG_RUN_SCRIPT } = process.env;
|
|
5
8
|
/**
|
|
@@ -21,6 +24,7 @@ const { DEBUG_RUN_SCRIPT } = process.env;
|
|
|
21
24
|
* Set env DEBUG_RUN_SCRIPT for extra debugging.
|
|
22
25
|
*/
|
|
23
26
|
export function runScript(fn, opt = {}) {
|
|
27
|
+
checkAndlogEnvironment();
|
|
24
28
|
setGlobalStringifyFunction(inspectStringifyFn);
|
|
25
29
|
const { logger = console, noExit, registerUncaughtExceptionHandlers = true } = opt;
|
|
26
30
|
if (registerUncaughtExceptionHandlers || DEBUG_RUN_SCRIPT) {
|
|
@@ -39,8 +43,6 @@ export function runScript(fn, opt = {}) {
|
|
|
39
43
|
const timeout = setTimeout(() => { }, 10000000);
|
|
40
44
|
void (async () => {
|
|
41
45
|
try {
|
|
42
|
-
await import('dotenv/config');
|
|
43
|
-
await checkAndlogEnvironment();
|
|
44
46
|
await fn();
|
|
45
47
|
await pDelay(); // to ensure all async operations are completed
|
|
46
48
|
if (DEBUG_RUN_SCRIPT)
|
|
@@ -61,8 +63,7 @@ export function runScript(fn, opt = {}) {
|
|
|
61
63
|
}
|
|
62
64
|
})();
|
|
63
65
|
}
|
|
64
|
-
|
|
65
|
-
const { dimGrey } = await import('../colors/colors.js');
|
|
66
|
+
function checkAndlogEnvironment() {
|
|
66
67
|
const { platform, arch, versions: { node }, env: { CPU_LIMIT, NODE_OPTIONS, TZ }, } = process;
|
|
67
68
|
const cpuLimit = Number(CPU_LIMIT) || undefined;
|
|
68
69
|
const availableParallelism = os.availableParallelism?.();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { _assert } from '@naturalcycles/js-lib';
|
|
3
|
+
import { _assert } from '@naturalcycles/js-lib/error';
|
|
4
4
|
import { globSync } from 'tinyglobby';
|
|
5
5
|
import { dimGrey, yellow } from '../colors/colors.js';
|
|
6
6
|
import { fs2 } from '../fs/fs2.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { _assert } from '@naturalcycles/js-lib';
|
|
3
|
+
import { _assert } from '@naturalcycles/js-lib/error';
|
|
4
4
|
import { globSync } from 'tinyglobby';
|
|
5
5
|
import { dimGrey, yellow } from '../colors/colors.js';
|
|
6
6
|
import { fs2 } from '../fs/fs2.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BinaryToTextEncoding } from 'node:crypto';
|
|
2
|
-
import type { Base64String, Base64UrlString } from '@naturalcycles/js-lib';
|
|
2
|
+
import type { Base64String, Base64UrlString } from '@naturalcycles/js-lib/types';
|
|
3
3
|
export declare function md5(s: string | Buffer, outputEncoding?: BinaryToTextEncoding): string;
|
|
4
4
|
export declare function md5AsBuffer(s: string | Buffer): Buffer;
|
|
5
5
|
export declare function sha256(s: string | Buffer, outputEncoding?: BinaryToTextEncoding): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Base64String, StringMap } from '@naturalcycles/js-lib';
|
|
1
|
+
import type { Base64String, StringMap } from '@naturalcycles/js-lib/types';
|
|
2
2
|
/**
|
|
3
3
|
* Loads plaintext secrets from process.env, removes them, stores locally.
|
|
4
4
|
* Make sure to call this function early on server startup, so secrets are removed from process.env
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { _assert
|
|
2
|
+
import { _assert } from '@naturalcycles/js-lib/error';
|
|
3
|
+
import { _jsonParseIfPossible } from '@naturalcycles/js-lib/string';
|
|
3
4
|
import { decryptObject, decryptRandomIVBuffer } from './crypto.util.js';
|
|
4
5
|
let loaded = false;
|
|
5
6
|
const secretMap = {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type CommonLogger, type CommonLogLevel } from '@naturalcycles/js-lib/log';
|
|
2
|
+
import type { AnyObject } from '@naturalcycles/js-lib/types';
|
|
2
3
|
import type { SlackAttachmentField, SlackMessage, SlackServiceCfg } from './slack.service.model.js';
|
|
3
4
|
/**
|
|
4
5
|
* Has 2 main methods:
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { localTime } from '@naturalcycles/js-lib/datetime';
|
|
2
|
+
import { getFetcher } from '@naturalcycles/js-lib/http';
|
|
3
|
+
import { commonLoggerMinLevel, } from '@naturalcycles/js-lib/log';
|
|
4
|
+
import { _omit } from '@naturalcycles/js-lib/object';
|
|
5
|
+
import { PQueue } from '@naturalcycles/js-lib/promise';
|
|
2
6
|
import { _inspect } from '../index.js';
|
|
3
7
|
const GAE = !!process.env['GAE_INSTANCE'];
|
|
4
8
|
const DEFAULTS = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
2
|
+
import type { AnyObject } from '@naturalcycles/js-lib/types';
|
|
3
|
+
import type { InspectAnyOptions } from '../string/inspect.js';
|
|
3
4
|
/**
|
|
4
5
|
* Properties that exists both in SlackApiBody (as per Slack API) and SlackMessage (our abstraction).
|
|
5
6
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { _hb
|
|
1
|
+
import { _hb } from '@naturalcycles/js-lib';
|
|
2
|
+
import { _ms } from '@naturalcycles/js-lib/datetime';
|
|
2
3
|
import { boldWhite, dimWhite } from '../../colors/colors.js';
|
|
3
4
|
export class NDJsonStats {
|
|
4
5
|
static create(o = {}) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AbortableAsyncMapper } from '@naturalcycles/js-lib';
|
|
1
|
+
import type { AbortableAsyncMapper } from '@naturalcycles/js-lib/types';
|
|
2
2
|
import { type TransformLogProgressOptions, type TransformMapOptions } from '../index.js';
|
|
3
3
|
export interface NDJSONMapOptions<IN = any, OUT = IN> extends TransformMapOptions<IN, OUT>, TransformLogProgressOptions<IN> {
|
|
4
4
|
inputFilePath: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorMode } from '@naturalcycles/js-lib';
|
|
1
|
+
import { ErrorMode } from '@naturalcycles/js-lib/error';
|
|
2
2
|
import { createReadStreamAsNDJSON, createWriteStreamAsNDJSON, } from '../index.js';
|
|
3
3
|
import { _pipeline, transformLimit, transformLogProgress, transformMap } from '../index.js';
|
|
4
4
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AbortableAsyncMapper } from '@naturalcycles/js-lib';
|
|
2
|
-
import { type TransformLogProgressOptions
|
|
1
|
+
import type { AbortableAsyncMapper } from '@naturalcycles/js-lib/types';
|
|
2
|
+
import { type TransformLogProgressOptions } from '../transform/transformLogProgress.js';
|
|
3
|
+
import { type TransformMapOptions } from '../transform/transformMap.js';
|
|
3
4
|
export interface NDJSONStreamForEachOptions<IN = any> extends TransformMapOptions<IN, void>, TransformLogProgressOptions<IN> {
|
|
4
5
|
inputFilePath: string;
|
|
5
6
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { ErrorMode } from '@naturalcycles/js-lib';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ErrorMode } from '@naturalcycles/js-lib/error';
|
|
2
|
+
import { _pipeline } from '../pipeline/pipeline.js';
|
|
3
|
+
import { transformLogProgress, } from '../transform/transformLogProgress.js';
|
|
4
|
+
import { transformMap } from '../transform/transformMap.js';
|
|
5
|
+
import { writableVoid } from '../writable/writableVoid.js';
|
|
6
|
+
import { createReadStreamAsNDJSON } from './createReadStreamAsNDJSON.js';
|
|
4
7
|
/**
|
|
5
8
|
* Convenience function to `forEach` through an ndjson file.
|
|
6
9
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transform } from 'node:stream';
|
|
2
|
-
import { _sortObjectDeep } from '@naturalcycles/js-lib';
|
|
2
|
+
import { _sortObjectDeep } from '@naturalcycles/js-lib/object';
|
|
3
3
|
/**
|
|
4
4
|
* Transforms objects (objectMode=true) into chunks \n-terminated JSON strings (readableObjectMode=false).
|
|
5
5
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
2
|
import { Transform } from 'node:stream';
|
|
3
|
-
import type { DeferredPromise } from '@naturalcycles/js-lib';
|
|
3
|
+
import type { DeferredPromise } from '@naturalcycles/js-lib/promise';
|
|
4
4
|
type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream;
|
|
5
5
|
export interface PipelineOptions {
|
|
6
6
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Transform } from 'node:stream';
|
|
2
2
|
import { pipeline } from 'node:stream/promises';
|
|
3
|
-
import { _last
|
|
3
|
+
import { _last } from '@naturalcycles/js-lib';
|
|
4
|
+
import { pDefer } from '@naturalcycles/js-lib/promise';
|
|
4
5
|
import { writablePushToArray } from '../writable/writablePushToArray.js';
|
|
5
6
|
/**
|
|
6
7
|
* Promisified `stream.pipeline`.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
2
|
+
import type { AnyObject } from '@naturalcycles/js-lib/types';
|
|
2
3
|
import type { ReadableMapper } from './stream.model.js';
|
|
3
4
|
export interface ProgressLoggerCfg<T = any> {
|
|
4
5
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { inspect } from 'node:util';
|
|
2
|
-
import { _mb
|
|
2
|
+
import { _mb } from '@naturalcycles/js-lib';
|
|
3
|
+
import { _since, localTime } from '@naturalcycles/js-lib/datetime';
|
|
4
|
+
import { SimpleMovingAverage } from '@naturalcycles/js-lib/math';
|
|
3
5
|
import { boldWhite, dimGrey, hasColors, white, yellow } from '../colors/colors.js';
|
|
4
6
|
import { SizeStack } from './sizeStack.js';
|
|
5
7
|
const inspectOpt = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AbortableAsyncMapper, IndexedMapper } from '@naturalcycles/js-lib';
|
|
2
|
-
import type { ReadableTyped } from '../
|
|
1
|
+
import type { AbortableAsyncMapper, IndexedMapper } from '@naturalcycles/js-lib/types';
|
|
2
|
+
import type { ReadableTyped } from '../stream.model.js';
|
|
3
3
|
import type { TransformMapOptions } from '../transform/transformMap.js';
|
|
4
4
|
/**
|
|
5
5
|
* Convenience function to do `.forEach` over a Readable.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _passNothingPredicate } from '@naturalcycles/js-lib';
|
|
2
|
-
import { _pipeline } from '../
|
|
1
|
+
import { _passNothingPredicate } from '@naturalcycles/js-lib/types';
|
|
2
|
+
import { _pipeline } from '../pipeline/pipeline.js';
|
|
3
3
|
import { transformMap } from '../transform/transformMap.js';
|
|
4
4
|
/**
|
|
5
5
|
* Convenience function to do `.forEach` over a Readable.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReadableOptions } from 'node:stream';
|
|
2
|
-
import type { AbortableAsyncMapper } from '@naturalcycles/js-lib';
|
|
2
|
+
import type { AbortableAsyncMapper } from '@naturalcycles/js-lib/types';
|
|
3
3
|
import type { ReadableTyped } from '../stream.model.js';
|
|
4
4
|
/**
|
|
5
5
|
* Create Readable from Array.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Readable } from 'node:stream';
|
|
2
|
-
import { _passthroughMapper } from '@naturalcycles/js-lib';
|
|
2
|
+
import { _passthroughMapper } from '@naturalcycles/js-lib/types';
|
|
3
3
|
/**
|
|
4
4
|
* Create Readable from Array.
|
|
5
5
|
* Supports a `mapper` function (async) that you can use to e.g create a timer-emitting-readable.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CommonLogger } from '@naturalcycles/js-lib';
|
|
2
|
-
import { NumberStack } from '@naturalcycles/js-lib';
|
|
1
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
2
|
+
import { NumberStack } from '@naturalcycles/js-lib/math';
|
|
3
3
|
export declare class SizeStack extends NumberStack {
|
|
4
4
|
name: string;
|
|
5
5
|
constructor(name: string, size: number);
|
package/dist/stream/sizeStack.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { _hb
|
|
1
|
+
import { _hb } from '@naturalcycles/js-lib';
|
|
2
|
+
import { NumberStack } from '@naturalcycles/js-lib/math';
|
|
2
3
|
import { yellow } from '../colors/colors.js';
|
|
3
4
|
import { gzipBuffer } from '../zip/zip.util.js';
|
|
4
5
|
export class SizeStack extends NumberStack {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Readable, Transform, Writable } from 'node:stream';
|
|
2
|
-
import type { Promisable } from '@naturalcycles/js-lib';
|
|
2
|
+
import type { Promisable } from '@naturalcycles/js-lib/types';
|
|
3
3
|
export interface ReadableSignalOptions {
|
|
4
4
|
/** allows destroying the stream if the signal is aborted. */
|
|
5
5
|
signal?: AbortSignal;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
-
import type { CommonLogger } from '@naturalcycles/js-lib';
|
|
2
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
3
3
|
export declare function pipelineClose(name: string, readableDownstream: Readable, sourceReadable: Readable | undefined, streamDone: Promise<void> | undefined, logger: CommonLogger): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AsyncPredicate, Predicate } from '@naturalcycles/js-lib';
|
|
1
|
+
import type { AsyncPredicate, Predicate } from '@naturalcycles/js-lib/types';
|
|
2
2
|
import type { TransformOptions, TransformTyped } from '../stream.model.js';
|
|
3
3
|
import type { TransformMapOptions } from './transformMap.js';
|
|
4
4
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
-
import type { CommonLogger } from '@naturalcycles/js-lib';
|
|
3
|
-
import { AbortableTransform } from '../
|
|
2
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
3
|
+
import { AbortableTransform } from '../pipeline/pipeline.js';
|
|
4
4
|
import type { TransformOptions, TransformTyped } from '../stream.model.js';
|
|
5
5
|
export interface TransformLimitOptions extends TransformOptions {
|
|
6
6
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AbortableTransform
|
|
1
|
+
import { AbortableTransform } from '../pipeline/pipeline.js';
|
|
2
2
|
import { pipelineClose } from '../stream.util.js';
|
|
3
|
+
import { transformNoOp } from './transformNoOp.js';
|
|
3
4
|
/**
|
|
4
5
|
* Class only exists to be able to do `instanceof TransformLimit`
|
|
5
6
|
* and to set sourceReadable+streamDone to it in `_pipeline`.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { ErrorMode } from '@naturalcycles/js-lib/error';
|
|
2
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
3
|
+
import { type AbortableAsyncMapper, type AsyncPredicate, END, type Promisable, SKIP, type StringMap, type UnixTimestampMillis } from '@naturalcycles/js-lib/types';
|
|
3
4
|
import type { TransformTyped } from '../stream.model.js';
|
|
4
5
|
export interface TransformMapOptions<IN = any, OUT = IN> {
|
|
5
6
|
/**
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _hc } from '@naturalcycles/js-lib';
|
|
2
|
+
import { _since } from '@naturalcycles/js-lib/datetime';
|
|
3
|
+
import { _anyToError, ErrorMode } from '@naturalcycles/js-lib/error';
|
|
4
|
+
import { pFilter } from '@naturalcycles/js-lib/promise';
|
|
5
|
+
import { _stringify } from '@naturalcycles/js-lib/string';
|
|
6
|
+
import { END, SKIP, } from '@naturalcycles/js-lib/types';
|
|
2
7
|
import through2Concurrent from 'through2-concurrent';
|
|
3
8
|
import { yellow } from '../../colors/colors.js';
|
|
4
9
|
import { pipelineClose } from '../stream.util.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { ErrorMode } from '@naturalcycles/js-lib/error';
|
|
2
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
3
|
+
import type { IndexedMapper } from '@naturalcycles/js-lib/types';
|
|
3
4
|
import type { TransformTyped } from '../stream.model.js';
|
|
4
5
|
export interface TransformMapSimpleOptions {
|
|
5
6
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { ErrorMode } from '@naturalcycles/js-lib/error';
|
|
2
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
3
|
+
import type { IndexedMapper, Predicate } from '@naturalcycles/js-lib/types';
|
|
4
|
+
import { END, SKIP } from '@naturalcycles/js-lib/types';
|
|
3
5
|
import { AbortableTransform } from '../pipeline/pipeline.js';
|
|
4
6
|
import type { TransformTyped } from '../stream.model.js';
|
|
5
7
|
import type { TransformMapStats } from './transformMap.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { _anyToError,
|
|
1
|
+
import { _anyToError, ErrorMode } from '@naturalcycles/js-lib/error';
|
|
2
|
+
import { END, SKIP } from '@naturalcycles/js-lib/types';
|
|
2
3
|
import { yellow } from '../../colors/colors.js';
|
|
3
4
|
import { AbortableTransform } from '../pipeline/pipeline.js';
|
|
4
5
|
import { pipelineClose } from '../stream.util.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CommonLogger } from '@naturalcycles/js-lib/log';
|
|
2
|
+
import type { AsyncIndexedMapper } from '@naturalcycles/js-lib/types';
|
|
2
3
|
import type { TransformOptions, TransformTyped } from '../stream.model.js';
|
|
3
4
|
export interface TransformTapOptions extends TransformOptions {
|
|
4
5
|
logger?: CommonLogger;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NumberOfSeconds, PositiveInteger } from '@naturalcycles/js-lib';
|
|
1
|
+
import type { NumberOfSeconds, PositiveInteger } from '@naturalcycles/js-lib/types';
|
|
2
2
|
import type { TransformTyped } from '../stream.model.js';
|
|
3
3
|
export interface TransformThrottleOptions {
|
|
4
4
|
/**
|