@naturalcycles/nodejs-lib 13.1.0 → 13.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/bin/del.js +3 -2
  2. package/dist/bin/generate-build-info.js +8 -7
  3. package/dist/bin/json2env.js +3 -2
  4. package/dist/bin/kpy.js +3 -2
  5. package/dist/bin/secrets-decrypt.js +3 -2
  6. package/dist/bin/secrets-encrypt.js +3 -2
  7. package/dist/bin/secrets-gen-key.js +5 -4
  8. package/dist/bin/slack-this.js +3 -2
  9. package/dist/colors/colors.d.ts +1 -1
  10. package/dist/colors/colors.js +31 -30
  11. package/dist/fs/del.js +11 -10
  12. package/dist/fs/fs.util.d.ts +1 -1
  13. package/dist/fs/fs.util.js +42 -41
  14. package/dist/fs/json2env.js +6 -5
  15. package/dist/fs/kpy.js +8 -7
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.js +5 -5
  18. package/dist/infra/process.util.js +8 -7
  19. package/dist/jwt/jwt.service.d.ts +1 -1
  20. package/dist/jwt/jwt.service.js +6 -5
  21. package/dist/secret/secrets-decrypt.util.js +9 -8
  22. package/dist/secret/secrets-encrypt.util.js +8 -7
  23. package/dist/security/crypto.util.js +9 -8
  24. package/dist/security/hash.util.js +4 -3
  25. package/dist/security/id.util.js +4 -3
  26. package/dist/security/secret.util.js +7 -6
  27. package/dist/stream/ndjson/ndjsonStreamForEach.js +3 -2
  28. package/dist/stream/ndjson/pipelineFromNDJsonFile.js +4 -3
  29. package/dist/stream/ndjson/pipelineToNDJsonFile.js +4 -3
  30. package/dist/stream/transform/transformLogProgress.js +1 -1
  31. package/dist/util/env.util.js +3 -2
  32. package/dist/util/exec.util.js +4 -3
  33. package/dist/util/git.util.js +9 -8
  34. package/dist/util/zip.util.js +6 -5
  35. package/dist/validation/ajv/getAjv.js +2 -1
  36. package/dist/validation/joi/joi.extensions.d.ts +1 -1
  37. package/dist/validation/joi/joi.extensions.js +3 -2
  38. package/dist/validation/joi/number.extensions.d.ts +1 -1
  39. package/dist/validation/joi/string.extensions.d.ts +1 -1
  40. package/package.json +2 -7
  41. package/src/bin/del.ts +1 -1
  42. package/src/bin/generate-build-info.ts +3 -3
  43. package/src/bin/json2env.ts +1 -1
  44. package/src/bin/kpy.ts +1 -1
  45. package/src/bin/secrets-decrypt.ts +1 -1
  46. package/src/bin/secrets-encrypt.ts +1 -1
  47. package/src/bin/secrets-gen-key.ts +2 -2
  48. package/src/bin/slack-this.ts +1 -1
  49. package/src/colors/colors.ts +2 -2
  50. package/src/fs/del.ts +2 -2
  51. package/src/fs/fs.util.ts +3 -3
  52. package/src/fs/json2env.ts +1 -1
  53. package/src/fs/kpy.ts +1 -1
  54. package/src/index.ts +2 -2
  55. package/src/infra/process.util.ts +1 -1
  56. package/src/jwt/jwt.service.ts +1 -1
  57. package/src/secret/secrets-decrypt.util.ts +2 -2
  58. package/src/secret/secrets-encrypt.util.ts +2 -2
  59. package/src/security/crypto.util.ts +1 -1
  60. package/src/security/hash.util.ts +1 -1
  61. package/src/security/id.util.ts +1 -1
  62. package/src/security/secret.util.ts +1 -1
  63. package/src/stream/ndjson/ndjsonStreamForEach.ts +1 -1
  64. package/src/stream/ndjson/pipelineFromNDJsonFile.ts +1 -1
  65. package/src/stream/ndjson/pipelineToNDJsonFile.ts +1 -1
  66. package/src/stream/transform/transformLogProgress.ts +1 -1
  67. package/src/util/env.util.ts +1 -1
  68. package/src/util/exec.util.ts +1 -1
  69. package/src/util/git.util.ts +2 -2
  70. package/src/util/zip.util.ts +1 -1
  71. package/src/validation/joi/joi.extensions.ts +1 -1
  72. package/src/validation/joi/number.extensions.ts +1 -1
  73. package/src/validation/joi/string.extensions.ts +1 -1
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Joi = void 0;
4
- const JoiLib = require("joi");
4
+ const tslib_1 = require("tslib");
5
+ const joi_1 = tslib_1.__importDefault(require("joi"));
5
6
  const number_extensions_1 = require("./number.extensions");
6
7
  const string_extensions_1 = require("./string.extensions");
7
8
  /**
8
9
  * This is the only right place to import Joi from
9
10
  */
10
11
  // eslint-disable-next-line @typescript-eslint/naming-convention
11
- exports.Joi = JoiLib.defaults(schema => {
12
+ exports.Joi = joi_1.default.defaults(schema => {
12
13
  // hack to prevent infinite recursion due to .empty('') where '' is a stringSchema itself
13
14
  if (schema.type === 'string') {
14
15
  return (schema
@@ -1,4 +1,4 @@
1
- import * as Joi from 'joi';
1
+ import Joi from 'joi';
2
2
  import { Extension, NumberSchema as JoiNumberSchema } from 'joi';
3
3
  export interface NumberSchema<TSchema = number> extends JoiNumberSchema<TSchema> {
4
4
  dividable: (q: number) => this;
@@ -1,5 +1,5 @@
1
1
  import { Extension, StringSchema as JoiStringSchema } from 'joi';
2
- import * as Joi from 'joi';
2
+ import Joi from 'joi';
3
3
  export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
4
4
  dateString: (min?: string, max?: string) => this;
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.1.0",
3
+ "version": "13.1.2",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -38,12 +38,7 @@
38
38
  "@naturalcycles/dev-lib": "^13.0.0",
39
39
  "@types/node": "^20.1.0",
40
40
  "@types/yargs": "^16.0.0",
41
- "jest": "^29.0.0",
42
- "nock": "^13.0.2",
43
- "prettier": "^3.0.0",
44
- "vue-class-component": "^7.2.6",
45
- "vuepress": "^1.7.1",
46
- "vuepress-plugin-typescript": "^0.3.1"
41
+ "jest": "^29.0.0"
47
42
  },
48
43
  "bin": {
49
44
  "del": "dist/bin/del.js",
package/src/bin/del.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as yargs from 'yargs'
3
+ import yargs from 'yargs'
4
4
  import { delSync } from '../fs/del'
5
5
  import { runScript } from '../script/runScript'
6
6
 
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as fs from 'node:fs'
4
- import * as path from 'node:path'
5
- import * as yargs from 'yargs'
3
+ import fs from 'node:fs'
4
+ import path from 'node:path'
5
+ import yargs from 'yargs'
6
6
  import { appendToBashEnv, appendToGithubEnv, appendToGithubOutput } from '../fs/json2env'
7
7
  import { runScript } from '../script/runScript'
8
8
  import { generateBuildInfo } from '../util/buildInfo.util'
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as yargs from 'yargs'
3
+ import yargs from 'yargs'
4
4
  import { json2env } from '../fs/json2env'
5
5
  import { runScript } from '../script/runScript'
6
6
 
package/src/bin/kpy.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as yargs from 'yargs'
3
+ import yargs from 'yargs'
4
4
  import { kpySync } from '../fs/kpy'
5
5
  import { runScript } from '../script/runScript'
6
6
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as yargs from 'yargs'
3
+ import yargs from 'yargs'
4
4
  import { dimGrey } from '../colors/colors'
5
5
  import { runScript } from '../script/runScript'
6
6
  import { DecryptCLIOptions, secretsDecrypt } from '../secret/secrets-decrypt.util'
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as yargs from 'yargs'
3
+ import yargs from 'yargs'
4
4
  import { dimGrey } from '../colors/colors'
5
5
  import { runScript } from '../script/runScript'
6
6
  import { EncryptCLIOptions, secretsEncrypt } from '../secret/secrets-encrypt.util'
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as crypto from 'node:crypto'
4
- import * as yargs from 'yargs'
3
+ import crypto from 'node:crypto'
4
+ import yargs from 'yargs'
5
5
  import { dimGrey } from '../colors/colors'
6
6
  import { runScript } from '../script/runScript'
7
7
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import * as yargs from 'yargs'
3
+ import yargs from 'yargs'
4
4
  import { SlackService } from '..'
5
5
  import { runScript } from '../script/runScript'
6
6
 
@@ -1,5 +1,5 @@
1
- import * as tty from 'node:tty'
2
- import * as chalk from 'chalk'
1
+ import tty from 'node:tty'
2
+ import chalk from 'chalk'
3
3
 
4
4
  export { chalk }
5
5
 
package/src/fs/del.ts CHANGED
@@ -1,5 +1,5 @@
1
- import * as fs from 'node:fs'
2
- import * as fsp from 'node:fs/promises'
1
+ import fs from 'node:fs'
2
+ import fsp from 'node:fs/promises'
3
3
  import { pFilter, pMap, _since } from '@naturalcycles/js-lib'
4
4
  import { dimGrey, yellow } from '../colors/colors'
5
5
  import { _pathExists, _pathExistsSync, globby } from '../index'
package/src/fs/fs.util.ts CHANGED
@@ -14,9 +14,9 @@ Credit to: fs-extra (https://github.com/jprichardson/node-fs-extra)
14
14
 
15
15
  */
16
16
 
17
- import * as fs from 'node:fs'
18
- import * as fsp from 'node:fs/promises'
19
- import * as path from 'node:path'
17
+ import fs from 'node:fs'
18
+ import fsp from 'node:fs/promises'
19
+ import path from 'node:path'
20
20
  import { _jsonParse } from '@naturalcycles/js-lib'
21
21
 
22
22
  /**
@@ -1,4 +1,4 @@
1
- import * as fs from 'node:fs'
1
+ import fs from 'node:fs'
2
2
  import { AnyObject } from '@naturalcycles/js-lib'
3
3
  import { dimGrey } from '../colors/colors'
4
4
  import { _pathExistsSync, _readJsonSync, _writeFileSync } from './fs.util'
package/src/fs/kpy.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as path from 'node:path'
1
+ import path from 'node:path'
2
2
  import { _since } from '@naturalcycles/js-lib'
3
3
  import { boldWhite, dimGrey, grey, yellow } from '../colors/colors'
4
4
  import {
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import Ajv from 'ajv'
2
- import * as fastGlob from 'fast-glob'
2
+ import fastGlob from 'fast-glob'
3
3
  import type { Options as FastGlobOptions } from 'fast-glob'
4
- import * as globby from 'globby'
4
+ import globby from 'globby'
5
5
  import type { GlobbyOptions } from 'globby'
6
6
  import type {
7
7
  AnySchema,
@@ -1,4 +1,4 @@
1
- import * as os from 'node:os'
1
+ import os from 'node:os'
2
2
  import { _mb } from '@naturalcycles/js-lib'
3
3
 
4
4
  export function memoryUsage(): {
@@ -1,7 +1,7 @@
1
1
  import { _assert, _errorDataAppend, AnyObject, ErrorData, JWTString } from '@naturalcycles/js-lib'
2
2
  import { AnySchema } from 'joi'
3
3
  import type { Algorithm, VerifyOptions, JwtHeader, SignOptions } from 'jsonwebtoken'
4
- import * as jsonwebtoken from 'jsonwebtoken'
4
+ import jsonwebtoken from 'jsonwebtoken'
5
5
  import { anyObjectSchema } from '../validation/joi/joi.shared.schemas'
6
6
  import { validate } from '../validation/joi/joi.validation.util'
7
7
  export { jsonwebtoken }
@@ -1,5 +1,5 @@
1
- import * as path from 'node:path'
2
- import * as fs from 'node:fs'
1
+ import path from 'node:path'
2
+ import fs from 'node:fs'
3
3
  import { _assert } from '@naturalcycles/js-lib'
4
4
  import { dimGrey, yellow } from '../colors/colors'
5
5
  import { _readJsonSync, _writeJsonSync, fastGlob } from '../index'
@@ -1,5 +1,5 @@
1
- import * as fs from 'node:fs'
2
- import * as path from 'node:path'
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
3
  import { _assert } from '@naturalcycles/js-lib'
4
4
  import { dimGrey, yellow } from '../colors/colors'
5
5
  import { _readJsonSync, _writeJsonSync, fastGlob } from '../index'
@@ -1,4 +1,4 @@
1
- import * as crypto from 'node:crypto'
1
+ import crypto from 'node:crypto'
2
2
  import { _stringMapEntries, Base64String, StringMap } from '@naturalcycles/js-lib'
3
3
  import { md5AsBuffer, sha256AsBuffer } from './hash.util'
4
4
 
@@ -1,4 +1,4 @@
1
- import * as crypto from 'node:crypto'
1
+ import crypto from 'node:crypto'
2
2
  import { Base64String } from '@naturalcycles/js-lib'
3
3
 
4
4
  export function md5(s: string | Buffer): string {
@@ -1,4 +1,4 @@
1
- import * as crypto from 'node:crypto'
1
+ import crypto from 'node:crypto'
2
2
  import {
3
3
  ALPHABET_ALPHANUMERIC,
4
4
  ALPHABET_ALPHANUMERIC_LOWERCASE,
@@ -1,4 +1,4 @@
1
- import * as fs from 'node:fs'
1
+ import fs from 'node:fs'
2
2
  import { _assert, _jsonParseIfPossible, Base64String, StringMap } from '@naturalcycles/js-lib'
3
3
  import { decryptObject, decryptRandomIVBuffer } from './crypto.util'
4
4
 
@@ -1,4 +1,4 @@
1
- import * as fs from 'node:fs'
1
+ import fs from 'node:fs'
2
2
  import { createUnzip } from 'node:zlib'
3
3
  import { AbortableAsyncMapper, ErrorMode } from '@naturalcycles/js-lib'
4
4
  import {
@@ -1,5 +1,5 @@
1
1
  import { createUnzip, ZlibOptions } from 'node:zlib'
2
- import * as fs from 'node:fs'
2
+ import fs from 'node:fs'
3
3
  import { _hb } from '@naturalcycles/js-lib'
4
4
  import { transformTap, _pipeline, transformSplit } from '../..'
5
5
  import { dimWhite, grey } from '../../colors/colors'
@@ -1,5 +1,5 @@
1
1
  import { createGzip, ZlibOptions } from 'node:zlib'
2
- import * as fs from 'node:fs'
2
+ import fs from 'node:fs'
3
3
  import { AppError } from '@naturalcycles/js-lib'
4
4
  import { transformTap, _pipeline, _pathExistsSync, _ensureFileSync } from '../..'
5
5
  import { grey } from '../../colors/colors'
@@ -224,7 +224,7 @@ export function transformLogProgress<IN = any>(
224
224
  lastSecondStarted = now
225
225
  processedLastSecond = 0
226
226
 
227
- const rps10 = Math.round(sma.push(lastRPS))
227
+ const rps10 = Math.round(sma.pushGetAvg(lastRPS))
228
228
  if (mem.rss > peakRSS) peakRSS = mem.rss
229
229
 
230
230
  const o: LogItem = {
@@ -1,4 +1,4 @@
1
- import * as fs from 'node:fs'
1
+ import fs from 'node:fs'
2
2
  import type { ValuesOf } from '@naturalcycles/js-lib'
3
3
  import 'dotenv/config' // ensure .env is read before requiring keys
4
4
 
@@ -1,5 +1,5 @@
1
1
  import type { ProcessEnvOptions, SpawnOptions } from 'node:child_process'
2
- import * as cp from 'node:child_process'
2
+ import cp from 'node:child_process'
3
3
 
4
4
  export async function execVoidCommand(
5
5
  cmd: string,
@@ -1,5 +1,5 @@
1
- import * as cp from 'node:child_process'
2
- import * as path from 'node:path'
1
+ import cp from 'node:child_process'
2
+ import path from 'node:path'
3
3
  import type { UnixTimestampNumber } from '@naturalcycles/js-lib'
4
4
  import { grey } from '../colors/colors'
5
5
 
@@ -1,6 +1,6 @@
1
1
  import { promisify } from 'node:util'
2
2
  import { ZlibOptions } from 'node:zlib'
3
- import * as zlib from 'node:zlib'
3
+ import zlib from 'node:zlib'
4
4
 
5
5
  const deflate = promisify(zlib.deflate.bind(zlib))
6
6
  const inflate = promisify(zlib.inflate.bind(zlib))
@@ -1,4 +1,4 @@
1
- import * as JoiLib from 'joi'
1
+ import JoiLib from 'joi'
2
2
  import { NumberSchema, numberExtensions } from './number.extensions'
3
3
  import { StringSchema, stringExtensions } from './string.extensions'
4
4
 
@@ -1,4 +1,4 @@
1
- import * as Joi from 'joi'
1
+ import Joi from 'joi'
2
2
  import { Extension, NumberSchema as JoiNumberSchema } from 'joi'
3
3
 
4
4
  export interface NumberSchema<TSchema = number> extends JoiNumberSchema<TSchema> {
@@ -1,6 +1,6 @@
1
1
  import { LocalDate, localTime } from '@naturalcycles/js-lib'
2
2
  import { Extension, StringSchema as JoiStringSchema } from 'joi'
3
- import * as Joi from 'joi'
3
+ import Joi from 'joi'
4
4
 
5
5
  export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
6
6
  dateString: (min?: string, max?: string) => this