@naturalcycles/nodejs-lib 15.1.0 → 15.3.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 (168) hide show
  1. package/dist/bin/slack-this.js +1 -1
  2. package/dist/{util → cache}/lruMemoCache.d.ts +1 -1
  3. package/dist/csv/csvReader.d.ts +1 -1
  4. package/dist/csv/csvReader.js +1 -1
  5. package/dist/csv/csvWriter.d.ts +1 -1
  6. package/dist/csv/csvWriter.js +1 -1
  7. package/dist/csv/transformToCSV.d.ts +1 -1
  8. package/dist/diff/tableDiff.d.ts +1 -1
  9. package/dist/diff/tableDiff.js +1 -1
  10. package/dist/{util/exec2.d.ts → exec2.d.ts} +2 -2
  11. package/dist/{util/exec2.js → exec2.js} +4 -3
  12. package/dist/fs/fs2.d.ts +0 -10
  13. package/dist/fs/fs2.js +1 -85
  14. package/dist/fs/json2env.d.ts +1 -1
  15. package/dist/fs/kpy.js +1 -1
  16. package/dist/fs/yaml2.d.ts +11 -0
  17. package/dist/fs/yaml2.js +29 -0
  18. package/dist/index.d.ts +0 -4
  19. package/dist/index.js +0 -4
  20. package/dist/jwt/jwt.service.d.ts +2 -1
  21. package/dist/jwt/jwt.service.js +1 -1
  22. package/dist/log/log.util.d.ts +1 -1
  23. package/dist/log/log.util.js +1 -1
  24. package/dist/script/runScript.d.ts +1 -2
  25. package/dist/script/runScript.js +6 -5
  26. package/dist/secret/secrets-decrypt.util.js +1 -1
  27. package/dist/secret/secrets-encrypt.util.js +1 -1
  28. package/dist/security/crypto.util.d.ts +1 -1
  29. package/dist/security/crypto.util.js +1 -1
  30. package/dist/security/hash.util.d.ts +1 -1
  31. package/dist/security/secret.util.d.ts +1 -1
  32. package/dist/security/secret.util.js +2 -1
  33. package/dist/slack/slack.service.d.ts +2 -1
  34. package/dist/slack/slack.service.js +5 -1
  35. package/dist/slack/slack.service.model.d.ts +2 -1
  36. package/dist/stream/index.d.ts +2 -0
  37. package/dist/stream/index.js +2 -0
  38. package/dist/stream/ndjson/createReadStreamAsNDJSON.d.ts +19 -0
  39. package/dist/stream/ndjson/createReadStreamAsNDJSON.js +38 -0
  40. package/dist/stream/ndjson/createWriteStreamAsNDJSON.d.ts +11 -0
  41. package/dist/stream/ndjson/createWriteStreamAsNDJSON.js +27 -0
  42. package/dist/stream/ndjson/ndjson.model.js +2 -1
  43. package/dist/stream/ndjson/ndjsonMap.d.ts +2 -2
  44. package/dist/stream/ndjson/ndjsonMap.js +4 -6
  45. package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +2 -2
  46. package/dist/stream/ndjson/ndjsonStreamForEach.js +3 -3
  47. package/dist/stream/ndjson/transformJsonParse.d.ts +1 -1
  48. package/dist/stream/ndjson/transformToNDJson.js +1 -1
  49. package/dist/stream/pipeline/pipeline.d.ts +1 -1
  50. package/dist/stream/pipeline/pipeline.js +2 -1
  51. package/dist/stream/progressLogger.d.ts +2 -1
  52. package/dist/stream/progressLogger.js +3 -1
  53. package/dist/stream/readable/readableForEach.d.ts +1 -1
  54. package/dist/stream/readable/readableForEach.js +1 -1
  55. package/dist/stream/readable/readableFromArray.d.ts +1 -1
  56. package/dist/stream/readable/readableFromArray.js +1 -1
  57. package/dist/stream/sizeStack.d.ts +2 -2
  58. package/dist/stream/sizeStack.js +3 -2
  59. package/dist/stream/stream.model.d.ts +1 -1
  60. package/dist/stream/stream.util.d.ts +1 -1
  61. package/dist/stream/transform/transformFilter.d.ts +1 -1
  62. package/dist/stream/transform/transformLimit.d.ts +1 -1
  63. package/dist/stream/transform/transformMap.d.ts +3 -2
  64. package/dist/stream/transform/transformMap.js +6 -1
  65. package/dist/stream/transform/transformMapSimple.d.ts +3 -2
  66. package/dist/stream/transform/transformMapSimple.js +1 -1
  67. package/dist/stream/transform/transformMapSync.d.ts +4 -2
  68. package/dist/stream/transform/transformMapSync.js +2 -1
  69. package/dist/stream/transform/transformTap.d.ts +2 -1
  70. package/dist/stream/transform/transformThrottle.d.ts +1 -1
  71. package/dist/stream/transform/transformThrottle.js +2 -1
  72. package/dist/stream/transform/worker/transformMultiThreaded.d.ts +1 -1
  73. package/dist/stream/transform/worker/transformMultiThreaded.js +2 -1
  74. package/dist/stream/writable/writableForEach.d.ts +1 -1
  75. package/dist/stream/writable/writableForEach.js +1 -1
  76. package/dist/stream/writable/writableVoid.d.ts +1 -1
  77. package/dist/string/inspect.d.ts +1 -1
  78. package/dist/string/inspect.js +1 -1
  79. package/dist/util/buildInfo.util.d.ts +2 -1
  80. package/dist/util/buildInfo.util.js +2 -1
  81. package/dist/util/env.util.d.ts +1 -2
  82. package/dist/util/env.util.js +0 -1
  83. package/dist/util/git2.d.ts +1 -1
  84. package/dist/util/git2.js +2 -3
  85. package/dist/validation/ajv/ajv.util.d.ts +1 -1
  86. package/dist/validation/ajv/ajvSchema.d.ts +1 -1
  87. package/dist/validation/ajv/ajvSchema.js +4 -1
  88. package/dist/validation/ajv/ajvValidationError.d.ts +2 -2
  89. package/dist/validation/ajv/ajvValidationError.js +1 -1
  90. package/dist/validation/joi/joi.shared.schemas.d.ts +2 -2
  91. package/dist/validation/joi/joi.validation.error.d.ts +2 -2
  92. package/dist/validation/joi/joi.validation.error.js +1 -1
  93. package/dist/validation/joi/joi.validation.util.js +2 -1
  94. package/dist/validation/joi/string.extensions.d.ts +1 -1
  95. package/dist/validation/joi/string.extensions.js +1 -1
  96. package/dist/{util → zip}/zip.util.js +0 -1
  97. package/package.json +12 -5
  98. package/src/bin/generate-build-info.ts +1 -1
  99. package/src/bin/slack-this.ts +1 -1
  100. package/src/{util → cache}/lruMemoCache.ts +1 -1
  101. package/src/csv/csvReader.ts +2 -2
  102. package/src/csv/csvWriter.ts +2 -2
  103. package/src/csv/transformToCSV.ts +1 -1
  104. package/src/diff/tableDiff.ts +2 -2
  105. package/src/{util/exec2.ts → exec2.ts} +9 -8
  106. package/src/fs/fs2.ts +1 -101
  107. package/src/fs/json2env.ts +1 -1
  108. package/src/fs/kpy.ts +2 -2
  109. package/src/fs/yaml2.ts +37 -0
  110. package/src/index.ts +0 -4
  111. package/src/jwt/jwt.service.ts +3 -2
  112. package/src/log/log.util.ts +1 -1
  113. package/src/script/runScript.ts +10 -6
  114. package/src/secret/secrets-decrypt.util.ts +1 -1
  115. package/src/secret/secrets-encrypt.util.ts +1 -1
  116. package/src/security/crypto.util.ts +1 -2
  117. package/src/security/hash.util.ts +1 -1
  118. package/src/security/secret.util.ts +3 -2
  119. package/src/slack/slack.service.model.ts +2 -1
  120. package/src/slack/slack.service.ts +10 -2
  121. package/src/stream/index.ts +2 -0
  122. package/src/stream/ndjson/createReadStreamAsNDJSON.ts +46 -0
  123. package/src/stream/ndjson/createWriteStreamAsNDJSON.ts +30 -0
  124. package/src/stream/ndjson/ndjson.model.ts +2 -1
  125. package/src/stream/ndjson/ndjsonMap.ts +12 -8
  126. package/src/stream/ndjson/ndjsonStreamForEach.ts +8 -5
  127. package/src/stream/ndjson/transformJsonParse.ts +1 -1
  128. package/src/stream/ndjson/transformToNDJson.ts +1 -1
  129. package/src/stream/pipeline/pipeline.ts +4 -2
  130. package/src/stream/progressLogger.ts +5 -2
  131. package/src/stream/readable/readableForEach.ts +2 -2
  132. package/src/stream/readable/readableFromArray.ts +2 -2
  133. package/src/stream/sizeStack.ts +4 -3
  134. package/src/stream/stream.model.ts +1 -1
  135. package/src/stream/stream.util.ts +1 -1
  136. package/src/stream/transform/transformFilter.ts +1 -1
  137. package/src/stream/transform/transformLimit.ts +1 -1
  138. package/src/stream/transform/transformMap.ts +12 -15
  139. package/src/stream/transform/transformMapSimple.ts +3 -2
  140. package/src/stream/transform/transformMapSync.ts +4 -7
  141. package/src/stream/transform/transformTap.ts +2 -1
  142. package/src/stream/transform/transformThrottle.ts +4 -3
  143. package/src/stream/transform/worker/transformMultiThreaded.ts +4 -2
  144. package/src/stream/writable/writableForEach.ts +2 -2
  145. package/src/stream/writable/writableVoid.ts +1 -1
  146. package/src/string/inspect.ts +2 -2
  147. package/src/util/buildInfo.util.ts +4 -2
  148. package/src/util/env.util.ts +1 -2
  149. package/src/util/git2.ts +3 -4
  150. package/src/validation/ajv/ajv.util.ts +1 -1
  151. package/src/validation/ajv/ajvSchema.ts +5 -7
  152. package/src/validation/ajv/ajvValidationError.ts +2 -2
  153. package/src/validation/joi/joi.shared.schemas.ts +7 -7
  154. package/src/validation/joi/joi.validation.error.ts +2 -2
  155. package/src/validation/joi/joi.validation.util.ts +2 -1
  156. package/src/validation/joi/string.extensions.ts +2 -2
  157. package/src/{util → zip}/zip.util.ts +0 -2
  158. package/dist/fs/index.d.ts +0 -3
  159. package/dist/fs/index.js +0 -3
  160. package/dist/jwt/index.d.ts +0 -1
  161. package/dist/jwt/index.js +0 -1
  162. package/dist/yargs/index.d.ts +0 -1
  163. package/dist/yargs/index.js +0 -1
  164. package/src/fs/index.ts +0 -3
  165. package/src/jwt/index.ts +0 -1
  166. package/src/yargs/index.ts +0 -1
  167. /package/dist/{util → cache}/lruMemoCache.js +0 -0
  168. /package/dist/{util → zip}/zip.util.d.ts +0 -0
@@ -1,5 +1,5 @@
1
- import { ErrorMode } from '@naturalcycles/js-lib';
2
- import { fs2 } from '../../fs/index.js';
1
+ import { ErrorMode } from '@naturalcycles/js-lib/error';
2
+ import { createReadStreamAsNDJSON, createWriteStreamAsNDJSON, } from '../index.js';
3
3
  import { _pipeline, transformLimit, transformLogProgress, transformMap } from '../index.js';
4
4
  /**
5
5
  * Unzips input file automatically, if it ends with `.gz`.
@@ -11,9 +11,7 @@ export async function ndjsonMap(mapper, opt) {
11
11
  inputFilePath,
12
12
  outputFilePath,
13
13
  });
14
- const readable = fs2
15
- .createReadStreamAsNDJSON(inputFilePath)
16
- .take(limitInput || Number.POSITIVE_INFINITY);
14
+ const readable = createReadStreamAsNDJSON(inputFilePath).take(limitInput || Number.POSITIVE_INFINITY);
17
15
  await _pipeline([
18
16
  readable,
19
17
  transformLogProgress({ metric: 'read', ...opt }),
@@ -24,6 +22,6 @@ export async function ndjsonMap(mapper, opt) {
24
22
  }),
25
23
  transformLimit({ limit: limitOutput, sourceReadable: readable }),
26
24
  transformLogProgress({ metric: 'saved', logEvery: logEveryOutput }),
27
- ...fs2.createWriteStreamAsNDJSON(outputFilePath),
25
+ ...createWriteStreamAsNDJSON(outputFilePath),
28
26
  ]);
29
27
  }
@@ -1,5 +1,5 @@
1
- import type { AbortableAsyncMapper } from '@naturalcycles/js-lib';
2
- import type { TransformLogProgressOptions, TransformMapOptions } from '../index.js';
1
+ import type { AbortableAsyncMapper } from '@naturalcycles/js-lib/types';
2
+ import { type TransformLogProgressOptions, type TransformMapOptions } from '../index.js';
3
3
  export interface NDJSONStreamForEachOptions<IN = any> extends TransformMapOptions<IN, void>, TransformLogProgressOptions<IN> {
4
4
  inputFilePath: string;
5
5
  }
@@ -1,12 +1,12 @@
1
- import { ErrorMode } from '@naturalcycles/js-lib';
2
- import { fs2 } from '../../fs/index.js';
1
+ import { ErrorMode } from '@naturalcycles/js-lib/error';
2
+ import { createReadStreamAsNDJSON, } from '../index.js';
3
3
  import { _pipeline, transformLogProgress, transformMap, writableVoid } from '../index.js';
4
4
  /**
5
5
  * Convenience function to `forEach` through an ndjson file.
6
6
  */
7
7
  export async function ndjsonStreamForEach(mapper, opt) {
8
8
  await _pipeline([
9
- fs2.createReadStreamAsNDJSON(opt.inputFilePath),
9
+ createReadStreamAsNDJSON(opt.inputFilePath),
10
10
  transformMap(mapper, {
11
11
  errorMode: ErrorMode.THROW_AGGREGATED,
12
12
  ...opt,
@@ -1,4 +1,4 @@
1
- import type { Reviver } from '@naturalcycles/js-lib';
1
+ import type { Reviver } from '@naturalcycles/js-lib/types';
2
2
  import type { TransformTyped } from '../stream.model.js';
3
3
  export interface TransformJsonParseOptions {
4
4
  /**
@@ -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, pDefer } from '@naturalcycles/js-lib';
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 { AnyObject, CommonLogger } from '@naturalcycles/js-lib';
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, _since, localTime, SimpleMovingAverage } from '@naturalcycles/js-lib';
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,4 +1,4 @@
1
- import type { AbortableAsyncMapper, IndexedMapper } from '@naturalcycles/js-lib';
1
+ import type { AbortableAsyncMapper, IndexedMapper } from '@naturalcycles/js-lib/types';
2
2
  import type { ReadableTyped } from '../index.js';
3
3
  import type { TransformMapOptions } from '../transform/transformMap.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { _passNothingPredicate } from '@naturalcycles/js-lib';
1
+ import { _passNothingPredicate } from '@naturalcycles/js-lib/types';
2
2
  import { _pipeline } from '../index.js';
3
3
  import { transformMap } from '../transform/transformMap.js';
4
4
  /**
@@ -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);
@@ -1,6 +1,7 @@
1
- import { _hb, NumberStack } from '@naturalcycles/js-lib';
1
+ import { _hb } from '@naturalcycles/js-lib';
2
+ import { NumberStack } from '@naturalcycles/js-lib/math';
2
3
  import { yellow } from '../colors/colors.js';
3
- import { gzipBuffer } from '../util/zip.util.js';
4
+ import { gzipBuffer } from '../zip/zip.util.js';
4
5
  export class SizeStack extends NumberStack {
5
6
  name;
6
7
  constructor(name, size) {
@@ -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,5 +1,5 @@
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
  import { AbortableTransform } from '../index.js';
4
4
  import type { TransformOptions, TransformTyped } from '../stream.model.js';
5
5
  export interface TransformLimitOptions extends TransformOptions {
@@ -1,5 +1,6 @@
1
- import type { AbortableAsyncMapper, AsyncPredicate, CommonLogger, Promisable, StringMap, UnixTimestampMillis } from '@naturalcycles/js-lib';
2
- import { END, ErrorMode, SKIP } from '@naturalcycles/js-lib';
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 { _anyToError, _hc, _since, _stringify, END, ErrorMode, pFilter, SKIP, } from '@naturalcycles/js-lib';
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 type { CommonLogger, IndexedMapper } from '@naturalcycles/js-lib';
2
- import { ErrorMode } from '@naturalcycles/js-lib';
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,5 @@
1
1
  import { Transform } from 'node:stream';
2
- import { ErrorMode } from '@naturalcycles/js-lib';
2
+ import { ErrorMode } from '@naturalcycles/js-lib/error';
3
3
  /**
4
4
  * Simplest version of `transformMap`.
5
5
  * errorMode: IMMEDIATE
@@ -1,5 +1,7 @@
1
- import type { CommonLogger, IndexedMapper, Predicate } from '@naturalcycles/js-lib';
2
- import { END, ErrorMode, SKIP } from '@naturalcycles/js-lib';
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, END, ErrorMode, SKIP } from '@naturalcycles/js-lib';
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 { AsyncIndexedMapper, CommonLogger } from '@naturalcycles/js-lib';
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
  /**
@@ -1,5 +1,6 @@
1
1
  import { Transform } from 'node:stream';
2
- import { _ms, _since, localTime, pDefer } from '@naturalcycles/js-lib';
2
+ import { _ms, _since, localTime } from '@naturalcycles/js-lib/datetime';
3
+ import { pDefer } from '@naturalcycles/js-lib/promise';
3
4
  /**
4
5
  * Allows to throttle the throughput of the stream.
5
6
  * For example, when you have an API with rate limit of 5000 requests per minute,
@@ -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.model.js';
3
3
  export interface TransformMultiThreadedOptions {
4
4
  /**
@@ -1,5 +1,6 @@
1
1
  import { Worker } from 'node:worker_threads';
2
- import { _range, pDefer } from '@naturalcycles/js-lib';
2
+ import { _range } from '@naturalcycles/js-lib';
3
+ import { pDefer } from '@naturalcycles/js-lib/promise';
3
4
  import through2Concurrent from 'through2-concurrent';
4
5
  const workerProxyFilePath = `${import.meta.dirname}/workerClassProxy.js`;
5
6
  /**
@@ -1,4 +1,4 @@
1
- import type { AsyncIndexedMapper, IndexedMapper } from '@naturalcycles/js-lib';
1
+ import type { AsyncIndexedMapper, IndexedMapper } from '@naturalcycles/js-lib/types';
2
2
  import type { TransformMapOptions } from '../index.js';
3
3
  import type { WritableTyped } from '../stream.model.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { _passNothingPredicate } from '@naturalcycles/js-lib';
1
+ import { _passNothingPredicate } from '@naturalcycles/js-lib/types';
2
2
  import { transformMap, transformMapSync } from '../index.js';
3
3
  /**
4
4
  * Just an alias to transformMap that declares OUT as void.
@@ -1,5 +1,5 @@
1
1
  import { Writable } from 'node:stream';
2
- import type { DeferredPromise } from '@naturalcycles/js-lib';
2
+ import type { DeferredPromise } from '@naturalcycles/js-lib/promise';
3
3
  import type { TransformOptions } from '../stream.model.js';
4
4
  export interface WritableVoidOptions extends TransformOptions {
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import type { InspectOptions } from 'node:util';
2
- import type { JsonStringifyFunction, StringifyOptions } from '@naturalcycles/js-lib';
2
+ import type { JsonStringifyFunction, StringifyOptions } from '@naturalcycles/js-lib/string';
3
3
  export interface InspectAnyOptions extends StringifyOptions, InspectOptions {
4
4
  }
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { inspect } from 'node:util';
2
- import { _stringify } from '@naturalcycles/js-lib';
2
+ import { _stringify } from '@naturalcycles/js-lib/string';
3
3
  const INSPECT_OPT = {
4
4
  breakLength: 80, // default: ??
5
5
  depth: 10, // default: 2
@@ -1,4 +1,5 @@
1
- import type { BuildInfo, UnixTimestamp } from '@naturalcycles/js-lib';
1
+ import type { BuildInfo } from '@naturalcycles/js-lib';
2
+ import type { UnixTimestamp } from '@naturalcycles/js-lib/types';
2
3
  export interface GenerateBuildInfoOptions {
3
4
  /**
4
5
  * If set - this timestamp will be used, instead of "current time".
@@ -1,4 +1,5 @@
1
- import { _filterUndefinedValues, localTime } from '@naturalcycles/js-lib';
1
+ import { localTime } from '@naturalcycles/js-lib/datetime';
2
+ import { _filterUndefinedValues } from '@naturalcycles/js-lib/object';
2
3
  import { fs2 } from '../fs/fs2.js';
3
4
  import { git2 } from './git2.js';
4
5
  export function generateBuildInfo(opt = {}) {
@@ -1,5 +1,4 @@
1
- import 'dotenv/config';
2
- import type { ValuesOf } from '@naturalcycles/js-lib';
1
+ import type { ValuesOf } from '@naturalcycles/js-lib/types';
3
2
  /**
4
3
  * @example
5
4
  *
@@ -1,4 +1,3 @@
1
- import 'dotenv/config'; // ensure .env is read before requiring keys
2
1
  import { fs2 } from '../fs/fs2.js';
3
2
  /**
4
3
  * @example
@@ -1,4 +1,4 @@
1
- import type { UnixTimestamp } from '@naturalcycles/js-lib';
1
+ import type { UnixTimestamp } from '@naturalcycles/js-lib/types';
2
2
  /**
3
3
  * Set of utility functions to work with git.
4
4
  */
package/dist/util/git2.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { execSync } from 'node:child_process';
2
2
  import { basename } from 'node:path';
3
- import { grey } from '../colors/colors.js';
4
- import { exec2 } from './exec2.js';
3
+ import { exec2 } from '../exec2.js';
5
4
  /**
6
5
  * Set of utility functions to work with git.
7
6
  */
@@ -34,7 +33,7 @@ class Git2 {
34
33
  const cmd = `git commit -a --no-verify -m "${msg}"`;
35
34
  // const cmd = `git`
36
35
  // const args = ['commit', '-a', '--no-verify', '-m', msg]
37
- console.log(grey(cmd));
36
+ console.log(cmd);
38
37
  try {
39
38
  execSync(cmd, {
40
39
  stdio: 'inherit',
@@ -1,4 +1,4 @@
1
- import type { JsonSchema } from '@naturalcycles/js-lib';
1
+ import type { JsonSchema } from '@naturalcycles/js-lib/json-schema';
2
2
  import type { GlobOptions } from 'tinyglobby';
3
3
  import type { AjvSchemaCfg } from './ajvSchema.js';
4
4
  import { AjvSchema } from './ajvSchema.js';
@@ -1,4 +1,4 @@
1
- import type { JsonSchema, JsonSchemaBuilder } from '@naturalcycles/js-lib';
1
+ import type { JsonSchema, JsonSchemaBuilder } from '@naturalcycles/js-lib/json-schema';
2
2
  import type { Ajv } from 'ajv';
3
3
  import { AjvValidationError } from './ajvValidationError.js';
4
4
  export interface AjvValidationOptions {
@@ -1,4 +1,7 @@
1
- import { _filterNullishValues, _isObject, _substringBefore, JsonSchemaAnyBuilder, } from '@naturalcycles/js-lib';
1
+ import { _isObject } from '@naturalcycles/js-lib';
2
+ import { JsonSchemaAnyBuilder } from '@naturalcycles/js-lib/json-schema';
3
+ import { _filterNullishValues } from '@naturalcycles/js-lib/object';
4
+ import { _substringBefore } from '@naturalcycles/js-lib/string';
2
5
  import { fs2 } from '../../fs/fs2.js';
3
6
  import { _inspect } from '../../string/inspect.js';
4
7
  import { AjvValidationError } from './ajvValidationError.js';
@@ -1,5 +1,5 @@
1
- import type { ErrorData } from '@naturalcycles/js-lib';
2
- import { AppError } from '@naturalcycles/js-lib';
1
+ import type { ErrorData } from '@naturalcycles/js-lib/error';
2
+ import { AppError } from '@naturalcycles/js-lib/error';
3
3
  import type { ErrorObject } from 'ajv';
4
4
  export interface AjvValidationErrorData extends ErrorData {
5
5
  errors: ErrorObject[];
@@ -1,4 +1,4 @@
1
- import { AppError } from '@naturalcycles/js-lib';
1
+ import { AppError } from '@naturalcycles/js-lib/error';
2
2
  export class AjvValidationError extends AppError {
3
3
  constructor(message, data) {
4
4
  super(message, data, {
@@ -1,4 +1,4 @@
1
- import type { BaseDBEntity, IANATimezone, IsoDateTime, NumberEnum, StringEnum, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib';
1
+ import type { BaseDBEntity, IANATimezone, IsoDateTime, NumberEnum, StringEnum, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib/types';
2
2
  import type { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi';
3
3
  import type { NumberSchema } from './number.extensions.js';
4
4
  import type { StringSchema } from './string.extensions.js';
@@ -10,7 +10,7 @@ export declare const numberSchema: NumberSchema<number>;
10
10
  export declare const numberSchemaTyped: <T>() => NumberSchema<T>;
11
11
  export declare const integerSchema: NumberSchema<number>;
12
12
  export declare const percentageSchema: NumberSchema<number>;
13
- export declare const dateStringSchema: StringSchema<import("@naturalcycles/js-lib").IsoDate>;
13
+ export declare const dateStringSchema: StringSchema<import("@naturalcycles/js-lib/types").IsoDate>;
14
14
  export declare const binarySchema: import("joi").BinarySchema<Buffer<ArrayBufferLike>>;
15
15
  export declare const dateObjectSchema: ObjectSchema<any>;
16
16
  export declare const dateIntervalStringSchema: StringSchema<string>;
@@ -1,5 +1,5 @@
1
- import type { ErrorData } from '@naturalcycles/js-lib';
2
- import { AppError } from '@naturalcycles/js-lib';
1
+ import type { ErrorData } from '@naturalcycles/js-lib/error';
2
+ import { AppError } from '@naturalcycles/js-lib/error';
3
3
  import type { ValidationErrorItem } from 'joi';
4
4
  /**
5
5
  * Example of ValidationErrorItem:
@@ -1,4 +1,4 @@
1
- import { AppError } from '@naturalcycles/js-lib';
1
+ import { AppError } from '@naturalcycles/js-lib/error';
2
2
  export class JoiValidationError extends AppError {
3
3
  constructor(message, data) {
4
4
  super(message, data, {
@@ -5,7 +5,8 @@
5
5
  *
6
6
  * "Converts" mean e.g trims all strings from leading/trailing spaces.
7
7
  */
8
- import { _hb, _isObject, _truncateMiddle } from '@naturalcycles/js-lib';
8
+ import { _hb, _isObject } from '@naturalcycles/js-lib';
9
+ import { _truncateMiddle } from '@naturalcycles/js-lib/string';
9
10
  import { JoiValidationError } from './joi.validation.error.js';
10
11
  // Strip colors in production (for e.g Sentry reporting)
11
12
  // const stripColors = process.env.NODE_ENV === 'production' || !!process.env.GAE_INSTANCE
@@ -1,4 +1,4 @@
1
- import type { IsoDate } from '@naturalcycles/js-lib';
1
+ import type { IsoDate } from '@naturalcycles/js-lib/types';
2
2
  import type Joi from 'joi';
3
3
  import type { Extension, StringSchema as JoiStringSchema } from 'joi';
4
4
  export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
@@ -1,4 +1,4 @@
1
- import { localTime } from '@naturalcycles/js-lib';
1
+ import { localTime } from '@naturalcycles/js-lib/datetime';
2
2
  export function stringExtensions(joi) {
3
3
  return {
4
4
  type: 'string',
@@ -4,7 +4,6 @@ const deflate = promisify(zlib.deflate.bind(zlib));
4
4
  const inflate = promisify(zlib.inflate.bind(zlib));
5
5
  const gzip = promisify(zlib.gzip.bind(zlib));
6
6
  const gunzip = promisify(zlib.gunzip.bind(zlib));
7
- // string > compressed buffer
8
7
  /**
9
8
  * deflateBuffer uses `deflate`.
10
9
  * It's 9 bytes shorter than `gzip`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.1.0",
4
+ "version": "15.3.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@types/js-yaml": "^4",
@@ -27,14 +27,21 @@
27
27
  },
28
28
  "exports": {
29
29
  ".": "./dist/index.js",
30
+ "./lruMemoCache": "./dist/cache/lruMemoCache.js",
31
+ "./colors": "./dist/colors/colors.js",
30
32
  "./csv": "./dist/csv/index.js",
31
- "./fs": "./dist/fs/index.js",
33
+ "./exec2": "./dist/exec2.js",
34
+ "./fs2": "./dist/fs/fs2.js",
35
+ "./env": "./dist/fs/json2env.js",
36
+ "./kpy": "./dist/fs/kpy.js",
37
+ "./yaml2": "./dist/fs/yaml2.js",
32
38
  "./glob": "./dist/glob/index.js",
33
- "./jwt": "./dist/jwt/index.js",
39
+ "./jwt": "./dist/jwt/jwt.service.js",
34
40
  "./stream": "./dist/stream/index.js",
35
- "./yargs": "./dist/yargs/index.js",
41
+ "./yargs": "./dist/yargs/yargs.util.js",
36
42
  "./ajv": "./dist/validation/ajv/index.js",
37
- "./joi": "./dist/validation/joi/index.js"
43
+ "./joi": "./dist/validation/joi/index.js",
44
+ "./zip": "./dist/zip/zip.util.js"
38
45
  },
39
46
  "bin": {
40
47
  "kpy": "dist/bin/kpy.js",
@@ -2,7 +2,7 @@
2
2
 
3
3
  import fs from 'node:fs'
4
4
  import path from 'node:path'
5
- import type { UnixTimestamp } from '@naturalcycles/js-lib'
5
+ import type { UnixTimestamp } from '@naturalcycles/js-lib/types'
6
6
  import { appendToBashEnv, appendToGithubEnv, appendToGithubOutput } from '../fs/json2env.js'
7
7
  import { runScript } from '../script/runScript.js'
8
8
  import { generateBuildInfo } from '../util/buildInfo.util.js'
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { SlackService } from '../index.js'
4
4
  import { runScript } from '../script/runScript.js'
5
- import { _yargs } from '../yargs/index.js'
5
+ import { _yargs } from '../yargs/yargs.util.js'
6
6
 
7
7
  runScript(async () => {
8
8
  const {
@@ -1,4 +1,4 @@
1
- import type { MemoCache } from '@naturalcycles/js-lib'
1
+ import type { MemoCache } from '@naturalcycles/js-lib/decorators'
2
2
  import { LRUCache } from 'lru-cache'
3
3
 
4
4
  // Partial, to be able to provide default `max`
@@ -1,7 +1,7 @@
1
1
  // Inspired by: https://gist.github.com/Jezternz/c8e9fafc2c114e079829974e3764db75
2
2
 
3
- import type { AnyObject } from '@naturalcycles/js-lib'
4
- import { _assert } from '@naturalcycles/js-lib'
3
+ import { _assert } from '@naturalcycles/js-lib/error'
4
+ import type { AnyObject } from '@naturalcycles/js-lib/types'
5
5
 
6
6
  export interface CSVReaderConfig {
7
7
  /**
@@ -1,7 +1,7 @@
1
1
  // Inspired by: https://github.com/ryu1kn/csv-writer/
2
2
 
3
- import type { AnyObject } from '@naturalcycles/js-lib'
4
- import { _assert } from '@naturalcycles/js-lib'
3
+ import { _assert } from '@naturalcycles/js-lib/error'
4
+ import type { AnyObject } from '@naturalcycles/js-lib/types'
5
5
 
6
6
  export interface CSVWriterConfig {
7
7
  /**
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import type { AnyObject } from '@naturalcycles/js-lib'
2
+ import type { AnyObject } from '@naturalcycles/js-lib/types'
3
3
  import type { TransformTyped } from '../stream/stream.model.js'
4
4
  import type { CSVWriterConfig } from './csvWriter.js'
5
5
  import { CSVWriter } from './csvWriter.js'
@@ -1,5 +1,5 @@
1
- import type { AnyObject } from '@naturalcycles/js-lib'
2
- import { _truncate } from '@naturalcycles/js-lib'
1
+ import { _truncate } from '@naturalcycles/js-lib/string'
2
+ import type { AnyObject } from '@naturalcycles/js-lib/types'
3
3
 
4
4
  export interface TableDiffOptions {
5
5
  /**