@naturalcycles/nodejs-lib 13.24.0 → 13.24.1
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/csv/csvReader.js +1 -1
- package/dist/slack/slack.service.js +1 -1
- package/dist/stream/progressLogger.js +1 -1
- package/dist/util/buildInfo.util.js +1 -1
- package/dist/validation/joi/string.extensions.js +2 -2
- package/package.json +2 -2
- package/src/csv/csvReader.ts +4 -1
- package/src/slack/slack.service.ts +2 -2
- package/src/stream/progressLogger.ts +2 -2
- package/src/util/buildInfo.util.ts +2 -2
- package/src/validation/joi/string.extensions.ts +3 -3
package/dist/csv/csvReader.js
CHANGED
|
@@ -34,7 +34,7 @@ function csvStringParse(str, cfg = {}) {
|
|
|
34
34
|
}
|
|
35
35
|
exports.csvStringParse = csvStringParse;
|
|
36
36
|
function csvStringToArray(str) {
|
|
37
|
-
const objPattern = new RegExp(
|
|
37
|
+
const objPattern = new RegExp(String.raw `(,|\r?\n|\r|^)(?:"([^"]*(?:""[^"]*)*)"|([^,\r\n]*))`, 'gi');
|
|
38
38
|
let matches;
|
|
39
39
|
const arr = [[]];
|
|
40
40
|
while ((matches = objPattern.exec(str))) {
|
|
@@ -130,7 +130,7 @@ class SlackService {
|
|
|
130
130
|
}
|
|
131
131
|
exports.SlackService = SlackService;
|
|
132
132
|
function slackDefaultMessagePrefixHook(msg) {
|
|
133
|
-
const tokens = [
|
|
133
|
+
const tokens = [js_lib_1.localTime.now().toPretty()];
|
|
134
134
|
const { ctx } = msg;
|
|
135
135
|
// AppEngine-specific decoration
|
|
136
136
|
if (GAE && ctx && typeof ctx === 'object' && typeof ctx.header === 'function') {
|
|
@@ -103,7 +103,7 @@ class ProgressLogger {
|
|
|
103
103
|
if (perHour > 900) {
|
|
104
104
|
perHour = Math.round(perHour / 1000) + 'K';
|
|
105
105
|
}
|
|
106
|
-
logger.log(`${(0, colors_1.dimGrey)(
|
|
106
|
+
logger.log(`${(0, colors_1.dimGrey)(js_lib_1.localTime.now().toPretty())} ${(0, colors_1.white)(metric)} took ${(0, colors_1.yellow)((0, js_lib_1._since)(this.started))} so far to process ${(0, colors_1.yellow)(batchedProgress)} rows, ~${(0, colors_1.yellow)(perHour)}/hour`);
|
|
107
107
|
}
|
|
108
108
|
else if (final) {
|
|
109
109
|
logger.log(`${(0, colors_1.boldWhite)(metric)} took ${(0, colors_1.yellow)((0, js_lib_1._since)(this.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 fs2_1 = require("../fs/fs2");
|
|
6
6
|
const git_util_1 = require("./git.util");
|
|
7
7
|
function generateBuildInfo(opt = {}) {
|
|
8
|
-
const now =
|
|
8
|
+
const now = js_lib_1.localTime.orNow(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)();
|
|
@@ -95,7 +95,7 @@ function getTodayStrPlus15() {
|
|
|
95
95
|
return todayStrPlusCached;
|
|
96
96
|
}
|
|
97
97
|
lastCheckedPlus = now;
|
|
98
|
-
return (todayStrPlusCached =
|
|
98
|
+
return (todayStrPlusCached = js_lib_1.localTime.now().plus(15, 'hour').toISODate());
|
|
99
99
|
}
|
|
100
100
|
function getTodayStrMinus15() {
|
|
101
101
|
const now = Date.now();
|
|
@@ -104,5 +104,5 @@ function getTodayStrMinus15() {
|
|
|
104
104
|
return todayStrMinusCached;
|
|
105
105
|
}
|
|
106
106
|
lastCheckedMinus = now;
|
|
107
|
-
return (todayStrMinusCached =
|
|
107
|
+
return (todayStrMinusCached = js_lib_1.localTime.now().plus(-15, 'hour').toISODate());
|
|
108
108
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
|
-
"version": "13.24.
|
|
3
|
+
"version": "13.24.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky",
|
|
6
6
|
"docs-serve": "vuepress dev docs",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"yargs": "^17.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@naturalcycles/bench-lib": "^
|
|
37
|
+
"@naturalcycles/bench-lib": "^3.0.0",
|
|
38
38
|
"@naturalcycles/dev-lib": "^13.0.0",
|
|
39
39
|
"@types/node": "^20.1.0",
|
|
40
40
|
"@types/yargs": "^16.0.0",
|
package/src/csv/csvReader.ts
CHANGED
|
@@ -56,7 +56,10 @@ export function csvStringParse<T extends AnyObject = any>(
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export function csvStringToArray(str: string): string[][] {
|
|
59
|
-
const objPattern = new RegExp(
|
|
59
|
+
const objPattern = new RegExp(
|
|
60
|
+
String.raw`(,|\r?\n|\r|^)(?:"([^"]*(?:""[^"]*)*)"|([^,\r\n]*))`,
|
|
61
|
+
'gi',
|
|
62
|
+
)
|
|
60
63
|
let matches: RegExpExecArray | null
|
|
61
64
|
const arr: any[][] = [[]]
|
|
62
65
|
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
CommonLogLevel,
|
|
7
7
|
Fetcher,
|
|
8
8
|
getFetcher,
|
|
9
|
-
|
|
9
|
+
localTime,
|
|
10
10
|
PQueue,
|
|
11
11
|
} from '@naturalcycles/js-lib'
|
|
12
12
|
import { _inspect, 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 = [localTime.now().toPretty()]
|
|
184
184
|
const { ctx } = msg
|
|
185
185
|
|
|
186
186
|
// AppEngine-specific decoration
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
_since,
|
|
5
5
|
AnyObject,
|
|
6
6
|
CommonLogger,
|
|
7
|
-
|
|
7
|
+
localTime,
|
|
8
8
|
SimpleMovingAverage,
|
|
9
9
|
UnixTimestampMillisNumber,
|
|
10
10
|
} from '@naturalcycles/js-lib'
|
|
@@ -294,7 +294,7 @@ export class ProgressLogger<T> implements Disposable {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
logger.log(
|
|
297
|
-
`${dimGrey(
|
|
297
|
+
`${dimGrey(localTime.now().toPretty())} ${white(metric)} took ${yellow(
|
|
298
298
|
_since(this.started),
|
|
299
299
|
)} so far to process ${yellow(batchedProgress)} rows, ~${yellow(perHour)}/hour`,
|
|
300
300
|
)
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
_filterUndefinedValues,
|
|
3
3
|
AnyObject,
|
|
4
4
|
BuildInfo,
|
|
5
|
-
|
|
5
|
+
localTime,
|
|
6
6
|
UnixTimestampNumber,
|
|
7
7
|
} from '@naturalcycles/js-lib'
|
|
8
8
|
import { fs2 } from '../fs/fs2'
|
|
@@ -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 = localTime.orNow(opt.overrideTimestamp)
|
|
25
25
|
const ts = now.unix()
|
|
26
26
|
|
|
27
27
|
const rev = gitCurrentCommitSha()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { localTime } from '@naturalcycles/js-lib'
|
|
2
2
|
import Joi, { Extension, StringSchema as JoiStringSchema } from 'joi'
|
|
3
3
|
|
|
4
4
|
export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
|
|
@@ -111,7 +111,7 @@ function getTodayStrPlus15(): string {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
lastCheckedPlus = now
|
|
114
|
-
return (todayStrPlusCached =
|
|
114
|
+
return (todayStrPlusCached = localTime.now().plus(15, 'hour').toISODate())
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
function getTodayStrMinus15(): string {
|
|
@@ -122,5 +122,5 @@ function getTodayStrMinus15(): string {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
lastCheckedMinus = now
|
|
125
|
-
return (todayStrMinusCached =
|
|
125
|
+
return (todayStrMinusCached = localTime.now().plus(-15, 'hour').toISODate())
|
|
126
126
|
}
|