@naturalcycles/nodejs-lib 13.44.0 → 13.45.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.
- package/dist/bin/generate-build-info.js +7 -7
- package/dist/bin/json2env.js +2 -2
- package/dist/bin/kpy.js +2 -2
- package/dist/bin/secrets-decrypt.js +2 -2
- package/dist/bin/secrets-encrypt.js +2 -2
- package/dist/bin/secrets-gen-key.js +4 -4
- package/dist/bin/slack-this.js +2 -2
- package/dist/colors/colors.js +2 -2
- package/dist/csv/csvReader.d.ts +1 -1
- package/dist/csv/csvWriter.d.ts +1 -1
- package/dist/csv/transformToCSV.d.ts +3 -3
- package/dist/diff/tableDiff.d.ts +1 -1
- package/dist/fs/fs2.d.ts +2 -2
- package/dist/fs/fs2.js +14 -14
- package/dist/fs/json2env.d.ts +1 -1
- package/dist/fs/json2env.js +5 -5
- package/dist/fs/kpy.js +8 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/infra/process.util.js +7 -7
- package/dist/jwt/jwt.service.d.ts +3 -3
- package/dist/jwt/jwt.service.js +5 -5
- package/dist/script/runScript.js +3 -3
- package/dist/secret/secrets-decrypt.util.js +4 -4
- package/dist/secret/secrets-encrypt.util.js +7 -7
- package/dist/security/crypto.util.d.ts +1 -1
- package/dist/security/crypto.util.js +9 -9
- package/dist/security/hash.util.d.ts +1 -1
- package/dist/security/hash.util.js +3 -7
- package/dist/security/id.util.js +3 -4
- package/dist/security/secret.util.d.ts +1 -1
- package/dist/security/secret.util.js +6 -7
- package/dist/slack/slack.service.d.ts +2 -2
- package/dist/slack/slack.service.model.d.ts +2 -2
- package/dist/stream/ndjson/ndjsonMap.d.ts +2 -2
- package/dist/stream/ndjson/ndjsonStreamForEach.d.ts +2 -2
- package/dist/stream/ndjson/transformJsonParse.d.ts +2 -2
- package/dist/stream/ndjson/transformToNDJson.d.ts +1 -1
- package/dist/stream/pipeline/pipeline.d.ts +3 -2
- package/dist/stream/progressLogger.d.ts +2 -2
- package/dist/stream/readable/readableCreate.d.ts +2 -2
- package/dist/stream/readable/readableForEach.d.ts +3 -3
- package/dist/stream/readable/readableFromArray.d.ts +3 -3
- package/dist/stream/readable/readableToArray.d.ts +1 -1
- package/dist/stream/sizeStack.d.ts +2 -1
- package/dist/stream/stream.util.d.ts +2 -2
- package/dist/stream/transform/transformChunk.d.ts +1 -1
- package/dist/stream/transform/transformFilter.d.ts +3 -3
- package/dist/stream/transform/transformLimit.d.ts +3 -3
- package/dist/stream/transform/transformLogProgress.d.ts +2 -2
- package/dist/stream/transform/transformMap.d.ts +3 -2
- package/dist/stream/transform/transformMapSimple.d.ts +3 -2
- package/dist/stream/transform/transformMapSync.d.ts +4 -3
- package/dist/stream/transform/transformNoOp.d.ts +1 -1
- package/dist/stream/transform/transformOffset.d.ts +1 -1
- package/dist/stream/transform/transformSplit.d.ts +1 -1
- package/dist/stream/transform/transformTap.d.ts +2 -2
- package/dist/stream/transform/transformTee.d.ts +1 -1
- package/dist/stream/transform/transformThrottle.d.ts +2 -2
- package/dist/stream/transform/transformToArray.d.ts +1 -1
- package/dist/stream/transform/worker/baseWorkerClass.d.ts +1 -1
- package/dist/stream/transform/worker/transformMultiThreaded.d.ts +2 -2
- package/dist/stream/writable/writableForEach.d.ts +3 -3
- package/dist/stream/writable/writableFork.d.ts +1 -1
- package/dist/stream/writable/writableLimit.d.ts +2 -2
- package/dist/stream/writable/writablePushToArray.d.ts +1 -1
- package/dist/stream/writable/writableVoid.d.ts +2 -2
- package/dist/string/inspect.d.ts +2 -2
- package/dist/util/buildInfo.util.d.ts +1 -1
- package/dist/util/env.util.js +2 -3
- package/dist/util/exec2.d.ts +2 -1
- package/dist/util/exec2.js +6 -9
- package/dist/util/git2.js +6 -7
- package/dist/util/lruMemoCache.d.ts +1 -1
- package/dist/util/zip.util.d.ts +1 -1
- package/dist/util/zip.util.js +5 -5
- package/dist/validation/ajv/ajv.util.d.ts +3 -2
- package/dist/validation/ajv/ajvSchema.d.ts +2 -2
- package/dist/validation/ajv/ajvValidationError.d.ts +2 -1
- package/dist/validation/joi/joi.extensions.d.ts +2 -2
- package/dist/validation/joi/joi.shared.schemas.d.ts +4 -4
- package/dist/validation/joi/joi.validation.error.d.ts +3 -2
- package/dist/validation/joi/joi.validation.util.d.ts +1 -1
- package/dist/validation/joi/number.extensions.d.ts +2 -2
- package/dist/validation/joi/string.extensions.d.ts +3 -3
- package/package.json +1 -1
- package/src/bin/generate-build-info.ts +4 -4
- package/src/bin/json2env.ts +1 -1
- package/src/bin/kpy.ts +1 -1
- package/src/bin/secrets-decrypt.ts +3 -2
- package/src/bin/secrets-encrypt.ts +3 -2
- package/src/bin/secrets-gen-key.ts +3 -3
- package/src/bin/slack-this.ts +1 -1
- package/src/colors/colors.ts +1 -1
- package/src/csv/csvReader.ts +2 -1
- package/src/csv/csvWriter.ts +2 -1
- package/src/csv/transformToCSV.ts +4 -3
- package/src/diff/tableDiff.ts +2 -1
- package/src/fs/fs2.ts +4 -3
- package/src/fs/json2env.ts +2 -2
- package/src/fs/kpy.ts +3 -2
- package/src/index.ts +1 -1
- package/src/infra/process.util.ts +1 -1
- package/src/jwt/jwt.service.ts +4 -3
- package/src/script/runScript.ts +1 -1
- package/src/secret/secrets-decrypt.util.ts +1 -1
- package/src/secret/secrets-encrypt.util.ts +2 -2
- package/src/security/crypto.util.ts +3 -2
- package/src/security/hash.util.ts +4 -6
- package/src/security/id.util.ts +3 -3
- package/src/security/secret.util.ts +8 -7
- package/src/slack/slack.service.model.ts +2 -2
- package/src/slack/slack.service.ts +5 -13
- package/src/stream/ndjson/ndjsonMap.ts +4 -10
- package/src/stream/ndjson/ndjsonStreamForEach.ts +4 -10
- package/src/stream/ndjson/transformJsonParse.ts +2 -2
- package/src/stream/ndjson/transformToNDJson.ts +1 -1
- package/src/stream/pipeline/pipeline.ts +4 -2
- package/src/stream/progressLogger.ts +5 -11
- package/src/stream/readable/readableCreate.ts +3 -2
- package/src/stream/readable/readableForEach.ts +6 -3
- package/src/stream/readable/readableFromArray.ts +5 -3
- package/src/stream/readable/readableToArray.ts +1 -1
- package/src/stream/sizeStack.ts +2 -1
- package/src/stream/stream.util.ts +2 -2
- package/src/stream/transform/transformChunk.ts +1 -1
- package/src/stream/transform/transformFilter.ts +4 -3
- package/src/stream/transform/transformLimit.ts +3 -3
- package/src/stream/transform/transformLogProgress.ts +3 -2
- package/src/stream/transform/transformMap.ts +10 -8
- package/src/stream/transform/transformMapSimple.ts +3 -2
- package/src/stream/transform/transformMapSync.ts +4 -12
- package/src/stream/transform/transformNoOp.ts +1 -1
- package/src/stream/transform/transformOffset.ts +1 -1
- package/src/stream/transform/transformSplit.ts +1 -1
- package/src/stream/transform/transformTap.ts +2 -2
- package/src/stream/transform/transformTee.ts +1 -1
- package/src/stream/transform/transformThrottle.ts +3 -6
- package/src/stream/transform/transformToArray.ts +1 -1
- package/src/stream/transform/worker/baseWorkerClass.ts +1 -1
- package/src/stream/transform/worker/transformMultiThreaded.ts +4 -3
- package/src/stream/writable/writableForEach.ts +5 -3
- package/src/stream/writable/writableFork.ts +3 -2
- package/src/stream/writable/writableLimit.ts +3 -2
- package/src/stream/writable/writablePushToArray.ts +1 -1
- package/src/stream/writable/writableVoid.ts +2 -2
- package/src/string/inspect.ts +4 -2
- package/src/util/buildInfo.util.ts +2 -7
- package/src/util/env.util.ts +2 -2
- package/src/util/exec2.ts +18 -25
- package/src/util/git2.ts +6 -6
- package/src/util/lruMemoCache.ts +1 -1
- package/src/util/zip.util.ts +2 -1
- package/src/validation/ajv/ajv.util.ts +3 -2
- package/src/validation/ajv/ajvSchema.ts +3 -4
- package/src/validation/ajv/ajvValidationError.ts +2 -1
- package/src/validation/joi/joi.extensions.ts +4 -2
- package/src/validation/joi/joi.shared.schemas.ts +10 -8
- package/src/validation/joi/joi.validation.error.ts +3 -2
- package/src/validation/joi/joi.validation.util.ts +3 -2
- package/src/validation/joi/number.extensions.ts +2 -2
- package/src/validation/joi/string.extensions.ts +4 -3
package/dist/util/git2.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.git2 = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
7
6
|
const colors_1 = require("../colors/colors");
|
|
8
7
|
const exec2_1 = require("./exec2");
|
|
9
8
|
/**
|
|
@@ -21,7 +20,7 @@ class Git2 {
|
|
|
21
20
|
hasUncommittedChanges() {
|
|
22
21
|
// git diff-index --quiet HEAD -- || echo "untracked"
|
|
23
22
|
try {
|
|
24
|
-
node_child_process_1.
|
|
23
|
+
(0, node_child_process_1.execSync)('git diff-index --quiet HEAD --', {
|
|
25
24
|
encoding: 'utf8',
|
|
26
25
|
});
|
|
27
26
|
return false;
|
|
@@ -40,7 +39,7 @@ class Git2 {
|
|
|
40
39
|
// const args = ['commit', '-a', '--no-verify', '-m', msg]
|
|
41
40
|
console.log((0, colors_1.grey)(cmd));
|
|
42
41
|
try {
|
|
43
|
-
node_child_process_1.
|
|
42
|
+
(0, node_child_process_1.execSync)(cmd, {
|
|
44
43
|
stdio: 'inherit',
|
|
45
44
|
});
|
|
46
45
|
return true;
|
|
@@ -62,7 +61,7 @@ class Git2 {
|
|
|
62
61
|
pull() {
|
|
63
62
|
const cmd = 'git pull';
|
|
64
63
|
try {
|
|
65
|
-
node_child_process_1.
|
|
64
|
+
(0, node_child_process_1.execSync)(cmd, {
|
|
66
65
|
stdio: 'inherit',
|
|
67
66
|
});
|
|
68
67
|
}
|
|
@@ -89,7 +88,7 @@ class Git2 {
|
|
|
89
88
|
}
|
|
90
89
|
getCurrentRepoName() {
|
|
91
90
|
const originUrl = exec2_1.exec2.exec('git config --get remote.origin.url');
|
|
92
|
-
return node_path_1.
|
|
91
|
+
return (0, node_path_1.basename)(originUrl, '.git');
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
exports.git2 = new Git2();
|
package/dist/util/zip.util.d.ts
CHANGED
package/dist/util/zip.util.js
CHANGED
|
@@ -10,11 +10,11 @@ exports.gzipString = gzipString;
|
|
|
10
10
|
exports.gunzipToString = gunzipToString;
|
|
11
11
|
const tslib_1 = require("tslib");
|
|
12
12
|
const node_util_1 = require("node:util");
|
|
13
|
-
const
|
|
14
|
-
const deflate = (0, node_util_1.promisify)(
|
|
15
|
-
const inflate = (0, node_util_1.promisify)(
|
|
16
|
-
const gzip = (0, node_util_1.promisify)(
|
|
17
|
-
const gunzip = (0, node_util_1.promisify)(
|
|
13
|
+
const zlib = tslib_1.__importStar(require("node:zlib"));
|
|
14
|
+
const deflate = (0, node_util_1.promisify)(zlib.deflate.bind(zlib));
|
|
15
|
+
const inflate = (0, node_util_1.promisify)(zlib.inflate.bind(zlib));
|
|
16
|
+
const gzip = (0, node_util_1.promisify)(zlib.gzip.bind(zlib));
|
|
17
|
+
const gunzip = (0, node_util_1.promisify)(zlib.gunzip.bind(zlib));
|
|
18
18
|
// string > compressed buffer
|
|
19
19
|
/**
|
|
20
20
|
* deflateBuffer uses `deflate`.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { JsonSchema } from '@naturalcycles/js-lib';
|
|
1
|
+
import type { JsonSchema } from '@naturalcycles/js-lib';
|
|
2
2
|
import type { FastGlobOptions } from '../..';
|
|
3
|
-
import {
|
|
3
|
+
import type { AjvSchemaCfg } from './ajvSchema';
|
|
4
|
+
import { AjvSchema } from './ajvSchema';
|
|
4
5
|
/**
|
|
5
6
|
* Does fs.readFileSync + JSON.parse for ALL files matching the passed `glob` pattern.
|
|
6
7
|
* E.g `someDir/**\/*.schema.json`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommonLogger, JsonSchema, JsonSchemaBuilder } from '@naturalcycles/js-lib';
|
|
2
|
-
import Ajv from 'ajv';
|
|
1
|
+
import type { CommonLogger, JsonSchema, JsonSchemaBuilder } from '@naturalcycles/js-lib';
|
|
2
|
+
import type Ajv from 'ajv';
|
|
3
3
|
import { AjvValidationError } from './ajvValidationError';
|
|
4
4
|
export interface AjvValidationOptions {
|
|
5
5
|
objectName?: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ErrorData } from '@naturalcycles/js-lib';
|
|
2
|
+
import { AppError } from '@naturalcycles/js-lib';
|
|
2
3
|
import type { ErrorObject } from 'ajv';
|
|
3
4
|
export interface AjvValidationErrorData extends ErrorData {
|
|
4
5
|
errors: ErrorObject[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import JoiLib from 'joi';
|
|
2
|
-
import { NumberSchema } from './number.extensions';
|
|
3
|
-
import { StringSchema } from './string.extensions';
|
|
2
|
+
import type { NumberSchema } from './number.extensions';
|
|
3
|
+
import type { StringSchema } from './string.extensions';
|
|
4
4
|
export interface ExtendedJoi extends JoiLib.Root {
|
|
5
5
|
string: <TSchema = string>() => StringSchema<TSchema>;
|
|
6
6
|
number: <TSchema = number>() => NumberSchema<TSchema>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BaseDBEntity, IANATimezone, IsoDateTime, NumberEnum, StringEnum, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib';
|
|
2
|
-
import { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi';
|
|
3
|
-
import { NumberSchema } from './number.extensions';
|
|
4
|
-
import { StringSchema } from './string.extensions';
|
|
1
|
+
import type { BaseDBEntity, IANATimezone, IsoDateTime, NumberEnum, StringEnum, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib';
|
|
2
|
+
import type { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi';
|
|
3
|
+
import type { NumberSchema } from './number.extensions';
|
|
4
|
+
import type { StringSchema } from './string.extensions';
|
|
5
5
|
export declare const booleanSchema: import("joi").BooleanSchema<boolean>;
|
|
6
6
|
export declare const booleanDefaultToFalseSchema: import("joi").BooleanSchema<boolean>;
|
|
7
7
|
export declare const stringSchema: StringSchema<string>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ErrorData } from '@naturalcycles/js-lib';
|
|
2
|
+
import { AppError } from '@naturalcycles/js-lib';
|
|
3
|
+
import type { ValidationErrorItem } from 'joi';
|
|
3
4
|
/**
|
|
4
5
|
* Example of ValidationErrorItem:
|
|
5
6
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type Joi from 'joi';
|
|
2
|
-
import { Extension, NumberSchema as JoiNumberSchema } from 'joi';
|
|
1
|
+
import type * as Joi from 'joi';
|
|
2
|
+
import type { Extension, NumberSchema as JoiNumberSchema } from 'joi';
|
|
3
3
|
export interface NumberSchema<TSchema = number> extends JoiNumberSchema<TSchema> {
|
|
4
4
|
dividable: (q: number) => this;
|
|
5
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IsoDate } from '@naturalcycles/js-lib';
|
|
2
|
-
import type Joi from 'joi';
|
|
3
|
-
import { Extension, StringSchema as JoiStringSchema } from 'joi';
|
|
1
|
+
import type { IsoDate } from '@naturalcycles/js-lib';
|
|
2
|
+
import type * as Joi from 'joi';
|
|
3
|
+
import type { Extension, StringSchema as JoiStringSchema } from 'joi';
|
|
4
4
|
export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
|
|
5
5
|
dateString: (min?: IsoDate | 'today', max?: IsoDate | 'today') => StringSchema<IsoDate>;
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import fs from 'node:fs'
|
|
4
|
-
import path from 'node:path'
|
|
5
|
-
import { UnixTimestamp } from '@naturalcycles/js-lib'
|
|
6
|
-
import yargs from 'yargs'
|
|
3
|
+
import * as fs from 'node:fs'
|
|
4
|
+
import * as path from 'node:path'
|
|
5
|
+
import type { UnixTimestamp } from '@naturalcycles/js-lib'
|
|
6
|
+
import * as yargs from 'yargs'
|
|
7
7
|
import { appendToBashEnv, appendToGithubEnv, appendToGithubOutput } from '../fs/json2env'
|
|
8
8
|
import { runScript } from '../script/runScript'
|
|
9
9
|
import { generateBuildInfo } from '../util/buildInfo.util'
|
package/src/bin/json2env.ts
CHANGED
package/src/bin/kpy.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import yargs from 'yargs'
|
|
3
|
+
import * as yargs from 'yargs'
|
|
4
4
|
import { dimGrey } from '../colors/colors'
|
|
5
5
|
import { runScript } from '../script/runScript'
|
|
6
|
-
import { DecryptCLIOptions
|
|
6
|
+
import type { DecryptCLIOptions } from '../secret/secrets-decrypt.util'
|
|
7
|
+
import { secretsDecrypt } from '../secret/secrets-decrypt.util'
|
|
7
8
|
|
|
8
9
|
runScript(() => {
|
|
9
10
|
const { dir, file, encKeyBuffer, del, jsonMode } = getDecryptCLIOptions()
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import yargs from 'yargs'
|
|
3
|
+
import * as yargs from 'yargs'
|
|
4
4
|
import { dimGrey } from '../colors/colors'
|
|
5
5
|
import { runScript } from '../script/runScript'
|
|
6
|
-
import { EncryptCLIOptions
|
|
6
|
+
import type { EncryptCLIOptions } from '../secret/secrets-encrypt.util'
|
|
7
|
+
import { secretsEncrypt } from '../secret/secrets-encrypt.util'
|
|
7
8
|
|
|
8
9
|
runScript(() => {
|
|
9
10
|
const { pattern, file, encKeyBuffer, del, jsonMode } = getEncryptCLIOptions()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import yargs from 'yargs'
|
|
3
|
+
import { randomBytes } from 'node:crypto'
|
|
4
|
+
import * as yargs from 'yargs'
|
|
5
5
|
import { dimGrey } from '../colors/colors'
|
|
6
6
|
import { runScript } from '../script/runScript'
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ runScript(() => {
|
|
|
11
11
|
default: 256,
|
|
12
12
|
}).argv
|
|
13
13
|
|
|
14
|
-
const key =
|
|
14
|
+
const key = randomBytes(sizeBytes).toString('base64')
|
|
15
15
|
|
|
16
16
|
console.log(dimGrey('\nSECRET_ENCRYPTION_KEY:\n'))
|
|
17
17
|
console.log(key, '\n')
|
package/src/bin/slack-this.ts
CHANGED
package/src/colors/colors.ts
CHANGED
package/src/csv/csvReader.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Inspired by: https://gist.github.com/Jezternz/c8e9fafc2c114e079829974e3764db75
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { AnyObject } from '@naturalcycles/js-lib'
|
|
4
|
+
import { _assert } from '@naturalcycles/js-lib'
|
|
4
5
|
|
|
5
6
|
export interface CSVReaderConfig {
|
|
6
7
|
/**
|
package/src/csv/csvWriter.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Inspired by: https://github.com/ryu1kn/csv-writer/
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import type { AnyObject } from '@naturalcycles/js-lib'
|
|
4
|
+
import { _assert } from '@naturalcycles/js-lib'
|
|
4
5
|
|
|
5
6
|
export interface CSVWriterConfig {
|
|
6
7
|
/**
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Transform } from 'node:stream'
|
|
2
|
-
import { AnyObject } from '@naturalcycles/js-lib'
|
|
3
|
-
import { TransformTyped } from '../stream/stream.model'
|
|
4
|
-
import {
|
|
2
|
+
import type { AnyObject } from '@naturalcycles/js-lib'
|
|
3
|
+
import type { TransformTyped } from '../stream/stream.model'
|
|
4
|
+
import type { CSVWriterConfig } from './csvWriter'
|
|
5
|
+
import { CSVWriter } from './csvWriter'
|
|
5
6
|
|
|
6
7
|
export interface TransformToCSVOptions extends CSVWriterConfig {
|
|
7
8
|
/**
|
package/src/diff/tableDiff.ts
CHANGED
package/src/fs/fs2.ts
CHANGED
|
@@ -17,12 +17,13 @@ Credit to: fs-extra (https://github.com/jprichardson/node-fs-extra)
|
|
|
17
17
|
import type { RmOptions, Stats } from 'node:fs'
|
|
18
18
|
import fs from 'node:fs'
|
|
19
19
|
import fsp from 'node:fs/promises'
|
|
20
|
-
import path from 'node:path'
|
|
20
|
+
import * as path from 'node:path'
|
|
21
21
|
import { createGzip, createUnzip } from 'node:zlib'
|
|
22
22
|
import { _isTruthy, _jsonParse } from '@naturalcycles/js-lib'
|
|
23
|
-
import
|
|
23
|
+
import type { DumpOptions } from 'js-yaml'
|
|
24
|
+
import * as yaml from 'js-yaml'
|
|
24
25
|
import { transformToNDJson } from '../stream/ndjson/transformToNDJson'
|
|
25
|
-
import { ReadableTyped, TransformTyped } from '../stream/stream.model'
|
|
26
|
+
import type { ReadableTyped, TransformTyped } from '../stream/stream.model'
|
|
26
27
|
import { transformSplitOnNewline } from '../stream/transform/transformSplit'
|
|
27
28
|
import { requireFileToExist } from '../util/env.util'
|
|
28
29
|
|
package/src/fs/json2env.ts
CHANGED
package/src/fs/kpy.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
import {
|
|
1
|
+
import * as path from 'node:path'
|
|
2
|
+
import type { UnixTimestampMillis } from '@naturalcycles/js-lib'
|
|
3
|
+
import { _since, localTime } from '@naturalcycles/js-lib'
|
|
3
4
|
import { boldWhite, dimGrey, grey, yellow } from '../colors/colors'
|
|
4
5
|
import { fastGlob, fs2 } from '../index'
|
|
5
6
|
|
package/src/index.ts
CHANGED
package/src/jwt/jwt.service.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { AnyObject, ErrorData, JWTString } from '@naturalcycles/js-lib'
|
|
2
|
+
import { _assert, _errorDataAppend } from '@naturalcycles/js-lib'
|
|
3
|
+
import type { AnySchema } from 'joi'
|
|
3
4
|
import type { Algorithm, JwtHeader, SignOptions, VerifyOptions } from 'jsonwebtoken'
|
|
4
|
-
import jsonwebtoken from 'jsonwebtoken'
|
|
5
|
+
import * as jsonwebtoken from 'jsonwebtoken'
|
|
5
6
|
import { anyObjectSchema } from '../validation/joi/joi.shared.schemas'
|
|
6
7
|
import { validate } from '../validation/joi/joi.validation.util'
|
|
7
8
|
export { jsonwebtoken }
|
package/src/script/runScript.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import fs from 'node:fs'
|
|
2
|
-
import path from 'node:path'
|
|
1
|
+
import * as fs from 'node:fs'
|
|
2
|
+
import * as path from 'node:path'
|
|
3
3
|
import { _assert } from '@naturalcycles/js-lib'
|
|
4
4
|
import { dimGrey, yellow } from '../colors/colors'
|
|
5
5
|
import { fastGlob, fs2 } from '../index'
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import crypto from 'node:crypto'
|
|
2
|
-
import {
|
|
1
|
+
import * as crypto from 'node:crypto'
|
|
2
|
+
import type { Base64String, StringMap } from '@naturalcycles/js-lib'
|
|
3
|
+
import { _stringMapEntries } from '@naturalcycles/js-lib'
|
|
3
4
|
import { md5AsBuffer, sha256AsBuffer } from './hash.util'
|
|
4
5
|
|
|
5
6
|
const algorithm = 'aes-256-cbc'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { BinaryToTextEncoding } from 'node:crypto'
|
|
2
|
+
import { hash as cryptoHash } from 'node:crypto'
|
|
2
3
|
import type { Base64String, Base64UrlString } from '@naturalcycles/js-lib'
|
|
3
4
|
|
|
4
5
|
export function md5(s: string | Buffer, outputEncoding: BinaryToTextEncoding = 'hex'): string {
|
|
@@ -22,14 +23,11 @@ export function hash(
|
|
|
22
23
|
algorithm: string,
|
|
23
24
|
outputEncoding: BinaryToTextEncoding = 'hex',
|
|
24
25
|
): string {
|
|
25
|
-
|
|
26
|
-
// Note: crypto.hash is Node 20.12+
|
|
27
|
-
return crypto.hash(algorithm, s, outputEncoding)
|
|
26
|
+
return cryptoHash(algorithm, s, outputEncoding)
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
export function hashAsBuffer(s: string | Buffer, algorithm: string): Buffer {
|
|
31
|
-
|
|
32
|
-
return crypto.hash(algorithm, s, 'buffer')
|
|
30
|
+
return cryptoHash(algorithm, s, 'buffer')
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
export function base64(s: string | Buffer): Base64String {
|
package/src/security/id.util.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { randomBytes } from 'node:crypto'
|
|
2
2
|
import {
|
|
3
3
|
ALPHABET_ALPHANUMERIC,
|
|
4
4
|
ALPHABET_ALPHANUMERIC_LOWERCASE,
|
|
@@ -30,7 +30,7 @@ export const stringIdBase62: () => string = nanoIdCustomAlphabet(ALPHABET_ALPHAN
|
|
|
30
30
|
* Dividable by 4 lengths produce ids with no padding `=` characters, which is optimal.
|
|
31
31
|
*/
|
|
32
32
|
export function stringIdBase64(size = 16): string {
|
|
33
|
-
return
|
|
33
|
+
return randomBytes(size * 0.75).toString('base64')
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -42,7 +42,7 @@ export function stringIdBase64(size = 16): string {
|
|
|
42
42
|
* Base64url always produces strings without a padding character `=`, by design.
|
|
43
43
|
*/
|
|
44
44
|
export function stringIdBase64Url(size = 16): string {
|
|
45
|
-
return
|
|
45
|
+
return randomBytes(size * 0.75).toString('base64url')
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
+
import type { Base64String, StringMap } from '@naturalcycles/js-lib'
|
|
3
|
+
import { _assert, _jsonParseIfPossible } from '@naturalcycles/js-lib'
|
|
3
4
|
import { decryptObject, decryptRandomIVBuffer } from './crypto.util'
|
|
4
5
|
|
|
5
6
|
let loaded = false
|
|
@@ -54,19 +55,19 @@ export function loadSecretsFromEncryptedJsonFile(
|
|
|
54
55
|
secretEncryptionKey?: Base64String,
|
|
55
56
|
): void {
|
|
56
57
|
_assert(
|
|
57
|
-
|
|
58
|
+
existsSync(filePath),
|
|
58
59
|
`loadSecretsFromEncryptedJsonFile() cannot load from path: ${filePath}`,
|
|
59
60
|
)
|
|
60
61
|
|
|
61
62
|
let secrets: StringMap
|
|
62
63
|
|
|
63
64
|
if (secretEncryptionKey) {
|
|
64
|
-
const buf =
|
|
65
|
+
const buf = readFileSync(filePath)
|
|
65
66
|
const encKeyBuffer = Buffer.from(secretEncryptionKey, 'base64')
|
|
66
67
|
const plain = decryptRandomIVBuffer(buf, encKeyBuffer).toString('utf8')
|
|
67
68
|
secrets = JSON.parse(plain)
|
|
68
69
|
} else {
|
|
69
|
-
secrets = JSON.parse(
|
|
70
|
+
secrets = JSON.parse(readFileSync(filePath, 'utf8'))
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
Object.entries(secrets).forEach(([k, v]) => (secretMap[k.toUpperCase()] = v))
|
|
@@ -88,11 +89,11 @@ export function loadSecretsFromEncryptedJsonFileValues(
|
|
|
88
89
|
secretEncryptionKey?: Base64String,
|
|
89
90
|
): void {
|
|
90
91
|
_assert(
|
|
91
|
-
|
|
92
|
+
existsSync(filePath),
|
|
92
93
|
`loadSecretsFromEncryptedJsonFileValues() cannot load from path: ${filePath}`,
|
|
93
94
|
)
|
|
94
95
|
|
|
95
|
-
let secrets: StringMap = JSON.parse(
|
|
96
|
+
let secrets: StringMap = JSON.parse(readFileSync(filePath, 'utf8'))
|
|
96
97
|
|
|
97
98
|
if (secretEncryptionKey) {
|
|
98
99
|
const encKeyBuffer = Buffer.from(secretEncryptionKey, 'base64')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnyObject, CommonLogger } from '@naturalcycles/js-lib'
|
|
2
|
-
import { InspectAnyOptions } from '..'
|
|
1
|
+
import type { AnyObject, CommonLogger } from '@naturalcycles/js-lib'
|
|
2
|
+
import type { InspectAnyOptions } from '..'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Properties that exists both in SlackApiBody (as per Slack API) and SlackMessage (our abstraction).
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
CommonLogLevel,
|
|
7
|
-
Fetcher,
|
|
8
|
-
getFetcher,
|
|
9
|
-
localTime,
|
|
10
|
-
PQueue,
|
|
11
|
-
} from '@naturalcycles/js-lib'
|
|
12
|
-
import { _inspect, InspectAnyOptions } from '..'
|
|
13
|
-
import {
|
|
1
|
+
import type { AnyObject, CommonLogger, CommonLogLevel, Fetcher } from '@naturalcycles/js-lib'
|
|
2
|
+
import { _omit, commonLoggerMinLevel, getFetcher, localTime, PQueue } from '@naturalcycles/js-lib'
|
|
3
|
+
import type { InspectAnyOptions } from '..'
|
|
4
|
+
import { _inspect } from '..'
|
|
5
|
+
import type {
|
|
14
6
|
SlackApiBody,
|
|
15
7
|
SlackAttachmentField,
|
|
16
8
|
SlackMessage,
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { AbortableAsyncMapper
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
transformLimit,
|
|
6
|
-
transformLogProgress,
|
|
7
|
-
TransformLogProgressOptions,
|
|
8
|
-
transformMap,
|
|
9
|
-
TransformMapOptions,
|
|
10
|
-
} from '../..'
|
|
1
|
+
import type { AbortableAsyncMapper } from '@naturalcycles/js-lib'
|
|
2
|
+
import { ErrorMode } from '@naturalcycles/js-lib'
|
|
3
|
+
import type { TransformLogProgressOptions, TransformMapOptions } from '../..'
|
|
4
|
+
import { _pipeline, fs2, transformLimit, transformLogProgress, transformMap } from '../..'
|
|
11
5
|
|
|
12
6
|
export interface NDJSONMapOptions<IN = any, OUT = IN>
|
|
13
7
|
extends TransformMapOptions<IN, OUT>,
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import { AbortableAsyncMapper
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
transformLogProgress,
|
|
6
|
-
TransformLogProgressOptions,
|
|
7
|
-
transformMap,
|
|
8
|
-
TransformMapOptions,
|
|
9
|
-
writableVoid,
|
|
10
|
-
} from '../..'
|
|
1
|
+
import type { AbortableAsyncMapper } from '@naturalcycles/js-lib'
|
|
2
|
+
import { ErrorMode } from '@naturalcycles/js-lib'
|
|
3
|
+
import type { TransformLogProgressOptions, TransformMapOptions } from '../..'
|
|
4
|
+
import { _pipeline, fs2, transformLogProgress, transformMap, writableVoid } from '../..'
|
|
11
5
|
|
|
12
6
|
export interface NDJSONStreamForEachOptions<IN = any>
|
|
13
7
|
extends TransformMapOptions<IN, void>,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Transform } from 'node:stream'
|
|
2
|
-
import { Reviver } from '@naturalcycles/js-lib'
|
|
3
|
-
import { TransformTyped } from '../stream.model'
|
|
2
|
+
import type { Reviver } from '@naturalcycles/js-lib'
|
|
3
|
+
import type { TransformTyped } from '../stream.model'
|
|
4
4
|
|
|
5
5
|
export interface TransformJsonParseOptions {
|
|
6
6
|
/**
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Readable,
|
|
1
|
+
import type { Readable, Writable } from 'node:stream'
|
|
2
|
+
import { Transform } from 'node:stream'
|
|
2
3
|
import { pipeline } from 'node:stream/promises'
|
|
3
|
-
import {
|
|
4
|
+
import type { AnyFunction, DeferredPromise } from '@naturalcycles/js-lib'
|
|
5
|
+
import { _last, pDefer } from '@naturalcycles/js-lib'
|
|
4
6
|
import { writablePushToArray } from '../writable/writablePushToArray'
|
|
5
7
|
|
|
6
8
|
type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream
|