@naturalcycles/nodejs-lib 13.1.2 → 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.
@@ -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.localTime)().toPretty()];
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");
@@ -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.localTime)().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`);
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.localTime)(opt.overrideTimestamp);
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.localTime)().add(14, 'hour').toISODate();
44
+ max = (0, js_lib_1.localTimeNow)().add(14, 'hour').toISODate();
45
45
  }
46
46
  if (min === 'today') {
47
- min = (0, js_lib_1.localTime)().subtract(14, 'hour').toISODate();
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.2",
3
+ "version": "13.1.3",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -1,5 +1,5 @@
1
- import path from 'node:path'
2
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'
@@ -6,7 +6,7 @@ import {
6
6
  CommonLogLevel,
7
7
  Fetcher,
8
8
  getFetcher,
9
- localTime,
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 = [localTime().toPretty()]
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
- localTime,
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'
@@ -260,7 +260,7 @@ export function transformLogProgress<IN = any>(
260
260
  }
261
261
 
262
262
  logger.log(
263
- `${dimGrey(localTime().toPretty())} ${white(metric)} took ${yellow(
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
- localTime,
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 = localTime(opt.overrideTimestamp)
24
+ const now = localTimeOrNow(opt.overrideTimestamp)
25
25
  const ts = now.unix()
26
26
 
27
27
  const rev = gitCurrentCommitSha()
@@ -1,6 +1,5 @@
1
1
  import { promisify } from 'node:util'
2
- import { ZlibOptions } from 'node:zlib'
3
- import zlib from 'node:zlib'
2
+ import zlib, { ZlibOptions } from 'node:zlib'
4
3
 
5
4
  const deflate = promisify(zlib.deflate.bind(zlib))
6
5
  const inflate = promisify(zlib.inflate.bind(zlib))
@@ -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, localTime } from '@naturalcycles/js-lib'
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 = localTime().add(14, 'hour').toISODate()
54
+ max = localTimeNow().add(14, 'hour').toISODate()
56
55
  }
57
56
  if (min === 'today') {
58
- min = localTime().subtract(14, 'hour').toISODate()
57
+ min = localTimeNow().subtract(14, 'hour').toISODate()
59
58
  }
60
59
  // console.log('min/max', min, max)
61
60