@naturalcycles/nodejs-lib 13.1.1 → 13.1.3
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/secret/secrets-decrypt.util.js +1 -1
- package/dist/slack/slack.service.js +1 -1
- package/dist/stream/ndjson/pipelineFromNDJsonFile.js +1 -1
- package/dist/stream/ndjson/pipelineToNDJsonFile.js +1 -1
- package/dist/stream/transform/transformLogProgress.js +2 -2
- package/dist/util/buildInfo.util.js +1 -1
- package/dist/validation/joi/number.extensions.d.ts +1 -2
- package/dist/validation/joi/string.extensions.d.ts +1 -2
- package/dist/validation/joi/string.extensions.js +2 -2
- package/package.json +2 -7
- package/src/secret/secrets-decrypt.util.ts +1 -1
- package/src/slack/slack.service.ts +2 -2
- package/src/stream/ndjson/pipelineFromNDJsonFile.ts +1 -1
- package/src/stream/ndjson/pipelineToNDJsonFile.ts +1 -1
- package/src/stream/transform/transformLogProgress.ts +3 -3
- package/src/util/buildInfo.util.ts +2 -2
- package/src/util/zip.util.ts +1 -2
- package/src/validation/joi/joi.validation.util.ts +2 -2
- package/src/validation/joi/number.extensions.ts +1 -2
- package/src/validation/joi/string.extensions.ts +4 -5
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.secretsDecrypt = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
6
5
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
|
+
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
8
|
const colors_1 = require("../colors/colors");
|
|
9
9
|
const index_1 = require("../index");
|
|
@@ -130,7 +130,7 @@ class SlackService {
|
|
|
130
130
|
}
|
|
131
131
|
exports.SlackService = SlackService;
|
|
132
132
|
function slackDefaultMessagePrefixHook(msg) {
|
|
133
|
-
const tokens = [(0, js_lib_1.
|
|
133
|
+
const tokens = [(0, js_lib_1.localTimeNow)().toPretty()];
|
|
134
134
|
const { ctx } = msg;
|
|
135
135
|
// AppEngine-specific decoration
|
|
136
136
|
if (GAE && ctx && typeof ctx === 'object' && typeof ctx.header === 'function') {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pipelineFromNDJsonFile = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const node_zlib_1 = require("node:zlib");
|
|
6
5
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
|
+
const node_zlib_1 = require("node:zlib");
|
|
7
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
8
|
const __1 = require("../..");
|
|
9
9
|
const colors_1 = require("../../colors/colors");
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pipelineToNDJsonFile = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const node_zlib_1 = require("node:zlib");
|
|
6
5
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
|
+
const node_zlib_1 = require("node:zlib");
|
|
7
7
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
8
8
|
const __1 = require("../..");
|
|
9
9
|
const colors_1 = require("../../colors/colors");
|
|
@@ -56,7 +56,7 @@ function transformLogProgress(opt = {}) {
|
|
|
56
56
|
const rpsTotal = Math.round(batchedProgress / ((now - started) / 1000)) || 0;
|
|
57
57
|
lastSecondStarted = now;
|
|
58
58
|
processedLastSecond = 0;
|
|
59
|
-
const rps10 = Math.round(sma.
|
|
59
|
+
const rps10 = Math.round(sma.pushGetAvg(lastRPS));
|
|
60
60
|
if (mem.rss > peakRSS)
|
|
61
61
|
peakRSS = mem.rss;
|
|
62
62
|
const o = {
|
|
@@ -92,7 +92,7 @@ function transformLogProgress(opt = {}) {
|
|
|
92
92
|
if (perHour > 900) {
|
|
93
93
|
perHour = Math.round(perHour / 1000) + 'K';
|
|
94
94
|
}
|
|
95
|
-
logger.log(`${(0, colors_1.dimGrey)((0, js_lib_1.
|
|
95
|
+
logger.log(`${(0, colors_1.dimGrey)((0, js_lib_1.localTimeNow)().toPretty())} ${(0, colors_1.white)(metric)} took ${(0, colors_1.yellow)((0, js_lib_1._since)(started))} so far to process ${(0, colors_1.yellow)(batchedProgress)} rows, ~${(0, colors_1.yellow)(perHour)}/hour`);
|
|
96
96
|
}
|
|
97
97
|
else if (final) {
|
|
98
98
|
logger.log(`${(0, colors_1.boldWhite)(metric)} took ${(0, colors_1.yellow)((0, js_lib_1._since)(started))} to process ${(0, colors_1.yellow)(batchedProgress)} rows with total RPS of ${(0, colors_1.yellow)(rpsTotal)}`);
|
|
@@ -5,7 +5,7 @@ const js_lib_1 = require("@naturalcycles/js-lib");
|
|
|
5
5
|
const fs_util_1 = require("../fs/fs.util");
|
|
6
6
|
const git_util_1 = require("./git.util");
|
|
7
7
|
function generateBuildInfo(opt = {}) {
|
|
8
|
-
const now = (0, js_lib_1.
|
|
8
|
+
const now = (0, js_lib_1.localTimeOrNow)(opt.overrideTimestamp);
|
|
9
9
|
const ts = now.unix();
|
|
10
10
|
const rev = (0, git_util_1.gitCurrentCommitSha)();
|
|
11
11
|
const branchName = (0, git_util_1.gitCurrentBranchName)();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
import { Extension, NumberSchema as JoiNumberSchema } from 'joi';
|
|
1
|
+
import Joi, { Extension, NumberSchema as JoiNumberSchema } from 'joi';
|
|
3
2
|
export interface NumberSchema<TSchema = number> extends JoiNumberSchema<TSchema> {
|
|
4
3
|
dividable: (q: number) => this;
|
|
5
4
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Extension, StringSchema as JoiStringSchema } from 'joi';
|
|
2
|
-
import Joi from 'joi';
|
|
1
|
+
import Joi, { Extension, StringSchema as JoiStringSchema } from 'joi';
|
|
3
2
|
export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
|
|
4
3
|
dateString: (min?: string, max?: string) => this;
|
|
5
4
|
}
|
|
@@ -41,10 +41,10 @@ function stringExtensions(joi) {
|
|
|
41
41
|
let { min, max } = args;
|
|
42
42
|
// Today allows +-14 hours gap to account for different timezones
|
|
43
43
|
if (max === 'today') {
|
|
44
|
-
max = (0, js_lib_1.
|
|
44
|
+
max = (0, js_lib_1.localTimeNow)().add(14, 'hour').toISODate();
|
|
45
45
|
}
|
|
46
46
|
if (min === 'today') {
|
|
47
|
-
min = (0, js_lib_1.
|
|
47
|
+
min = (0, js_lib_1.localTimeNow)().subtract(14, 'hour').toISODate();
|
|
48
48
|
}
|
|
49
49
|
// console.log('min/max', min, max)
|
|
50
50
|
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(v);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.3",
|
|
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",
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
CommonLogLevel,
|
|
7
7
|
Fetcher,
|
|
8
8
|
getFetcher,
|
|
9
|
-
|
|
9
|
+
localTimeNow,
|
|
10
10
|
PQueue,
|
|
11
11
|
} from '@naturalcycles/js-lib'
|
|
12
12
|
import { inspectAny, InspectAnyOptions } from '..'
|
|
@@ -180,7 +180,7 @@ export class SlackService<CTX = any> {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
export function slackDefaultMessagePrefixHook(msg: SlackMessage): string[] {
|
|
183
|
-
const tokens = [
|
|
183
|
+
const tokens = [localTimeNow().toPretty()]
|
|
184
184
|
const { ctx } = msg
|
|
185
185
|
|
|
186
186
|
// AppEngine-specific decoration
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createUnzip, ZlibOptions } from 'node:zlib'
|
|
2
1
|
import fs from 'node:fs'
|
|
2
|
+
import { createUnzip, ZlibOptions } from 'node:zlib'
|
|
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
|
-
import { createGzip, ZlibOptions } from 'node:zlib'
|
|
2
1
|
import fs from 'node:fs'
|
|
2
|
+
import { createGzip, ZlibOptions } from 'node:zlib'
|
|
3
3
|
import { AppError } from '@naturalcycles/js-lib'
|
|
4
4
|
import { transformTap, _pipeline, _pathExistsSync, _ensureFileSync } from '../..'
|
|
5
5
|
import { grey } from '../../colors/colors'
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
_since,
|
|
7
7
|
AnyObject,
|
|
8
8
|
CommonLogger,
|
|
9
|
-
|
|
9
|
+
localTimeNow,
|
|
10
10
|
} from '@naturalcycles/js-lib'
|
|
11
11
|
import { hasColors, boldWhite, dimGrey, white, yellow } from '../../colors/colors'
|
|
12
12
|
import { SizeStack } from '../sizeStack'
|
|
@@ -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.
|
|
227
|
+
const rps10 = Math.round(sma.pushGetAvg(lastRPS))
|
|
228
228
|
if (mem.rss > peakRSS) peakRSS = mem.rss
|
|
229
229
|
|
|
230
230
|
const o: LogItem = {
|
|
@@ -260,7 +260,7 @@ export function transformLogProgress<IN = any>(
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
logger.log(
|
|
263
|
-
`${dimGrey(
|
|
263
|
+
`${dimGrey(localTimeNow().toPretty())} ${white(metric)} took ${yellow(
|
|
264
264
|
_since(started),
|
|
265
265
|
)} so far to process ${yellow(batchedProgress)} rows, ~${yellow(perHour)}/hour`,
|
|
266
266
|
)
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
_filterUndefinedValues,
|
|
3
3
|
AnyObject,
|
|
4
4
|
BuildInfo,
|
|
5
|
-
|
|
5
|
+
localTimeOrNow,
|
|
6
6
|
UnixTimestampNumber,
|
|
7
7
|
} from '@naturalcycles/js-lib'
|
|
8
8
|
import { _pathExistsSync, _readJsonSync } from '../fs/fs.util'
|
|
@@ -21,7 +21,7 @@ export interface GenerateBuildInfoOptions {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export function generateBuildInfo(opt: GenerateBuildInfoOptions = {}): BuildInfo {
|
|
24
|
-
const now =
|
|
24
|
+
const now = localTimeOrNow(opt.overrideTimestamp)
|
|
25
25
|
const ts = now.unix()
|
|
26
26
|
|
|
27
27
|
const rev = gitCurrentCommitSha()
|
package/src/util/zip.util.ts
CHANGED
|
@@ -84,7 +84,7 @@ export function getValidationResult<T>(
|
|
|
84
84
|
})
|
|
85
85
|
|
|
86
86
|
const vr: JoiValidationResult<T> = {
|
|
87
|
-
value: returnValue
|
|
87
|
+
value: returnValue,
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
if (error) {
|
|
@@ -120,7 +120,7 @@ export function undefinedIfInvalid<T>(value: T, schema?: AnySchema<T>): T | unde
|
|
|
120
120
|
export function convert<T>(value: T, schema?: AnySchema<T>): T {
|
|
121
121
|
if (!schema) return value as any
|
|
122
122
|
const { value: returnValue } = schema.validate(value, defaultOptions)
|
|
123
|
-
return returnValue
|
|
123
|
+
return returnValue
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
function createError(value: any, err: ValidationError, objectName?: string): JoiValidationError {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import Joi from 'joi'
|
|
2
|
-
import { Extension, NumberSchema as JoiNumberSchema } from 'joi'
|
|
1
|
+
import Joi, { Extension, NumberSchema as JoiNumberSchema } from 'joi'
|
|
3
2
|
|
|
4
3
|
export interface NumberSchema<TSchema = number> extends JoiNumberSchema<TSchema> {
|
|
5
4
|
dividable: (q: number) => this
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { LocalDate,
|
|
2
|
-
import { Extension, StringSchema as JoiStringSchema } from 'joi'
|
|
3
|
-
import Joi from 'joi'
|
|
1
|
+
import { LocalDate, localTimeNow } from '@naturalcycles/js-lib'
|
|
2
|
+
import Joi, { Extension, StringSchema as JoiStringSchema } from 'joi'
|
|
4
3
|
|
|
5
4
|
export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
|
|
6
5
|
dateString: (min?: string, max?: string) => this
|
|
@@ -52,10 +51,10 @@ export function stringExtensions(joi: typeof Joi): Extension {
|
|
|
52
51
|
|
|
53
52
|
// Today allows +-14 hours gap to account for different timezones
|
|
54
53
|
if (max === 'today') {
|
|
55
|
-
max =
|
|
54
|
+
max = localTimeNow().add(14, 'hour').toISODate()
|
|
56
55
|
}
|
|
57
56
|
if (min === 'today') {
|
|
58
|
-
min =
|
|
57
|
+
min = localTimeNow().subtract(14, 'hour').toISODate()
|
|
59
58
|
}
|
|
60
59
|
// console.log('min/max', min, max)
|
|
61
60
|
|