@naturalcycles/nodejs-lib 12.83.0 → 12.85.0

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.
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runScript = void 0;
4
+ const js_lib_1 = require("@naturalcycles/js-lib");
5
+ const inspectAny_1 = require("../string/inspectAny");
4
6
  const { DEBUG_RUN_SCRIPT } = process.env;
5
7
  /**
6
8
  * Use it in your top-level scripts like this:
@@ -21,6 +23,7 @@ const { DEBUG_RUN_SCRIPT } = process.env;
21
23
  * Set env DEBUG_RUN_SCRIPT for extra debugging.
22
24
  */
23
25
  function runScript(fn, opt = {}) {
26
+ (0, js_lib_1.setGlobalStringifyFunction)(inspectAny_1.inspectAnyStringifyFn);
24
27
  const { logger = console, noExit } = opt;
25
28
  process.on('uncaughtException', err => {
26
29
  logger.error('uncaughtException:', err);
@@ -8,6 +8,7 @@ export declare const integerSchema: import("./number.extensions").ExtendedNumber
8
8
  export declare const percentageSchema: import("./number.extensions").ExtendedNumberSchema;
9
9
  export declare const dateStringSchema: import("./string.extensions").ExtendedStringSchema;
10
10
  export declare const binarySchema: import("joi").BinarySchema;
11
+ export declare const dateObjectSchema: import("joi").ObjectSchema<any>;
11
12
  export declare const urlSchema: (scheme?: string | string[]) => StringSchemaTyped;
12
13
  export declare function arraySchema<T>(items?: AnySchemaTyped<T, T>): ArraySchemaTyped<T>;
13
14
  export declare function objectSchema<IN, OUT = IN>(schema?: {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.savedDBEntitySchema = exports.baseDBEntitySchema = exports.ipAddressSchema = exports.utcOffsetSchema = exports.userAgentSchema = exports.semVerSchema = exports.SEM_VER_REGEX = exports.emailSchema = exports.verSchema = exports.unixTimestampMillis2000Schema = exports.unixTimestampMillisSchema = exports.unixTimestamp2000Schema = exports.unixTimestampSchema = exports.slugSchema = exports.SLUG_REGEX = exports.idBase64UrlSchema = exports.idBase64Schema = exports.idBase62Schema = exports.idSchema = exports.jwtSchema = exports.JWT_REGEX = exports.base64UrlSchema = exports.base64Schema = exports.base62Schema = exports.BASE64URL_REGEX = exports.BASE64_REGEX = exports.BASE62_REGEX = exports.anyObjectSchema = exports.anySchema = exports.oneOfSchema = exports.objectSchema = exports.arraySchema = exports.urlSchema = exports.binarySchema = exports.dateStringSchema = exports.percentageSchema = exports.integerSchema = exports.numberSchema = exports.stringSchema = exports.booleanDefaultToFalseSchema = exports.booleanSchema = void 0;
3
+ exports.savedDBEntitySchema = exports.baseDBEntitySchema = exports.ipAddressSchema = exports.utcOffsetSchema = exports.userAgentSchema = exports.semVerSchema = exports.SEM_VER_REGEX = exports.emailSchema = exports.verSchema = exports.unixTimestampMillis2000Schema = exports.unixTimestampMillisSchema = exports.unixTimestamp2000Schema = exports.unixTimestampSchema = exports.slugSchema = exports.SLUG_REGEX = exports.idBase64UrlSchema = exports.idBase64Schema = exports.idBase62Schema = exports.idSchema = exports.jwtSchema = exports.JWT_REGEX = exports.base64UrlSchema = exports.base64Schema = exports.base62Schema = exports.BASE64URL_REGEX = exports.BASE64_REGEX = exports.BASE62_REGEX = exports.anyObjectSchema = exports.anySchema = exports.oneOfSchema = exports.objectSchema = exports.arraySchema = exports.urlSchema = exports.dateObjectSchema = exports.binarySchema = exports.dateStringSchema = exports.percentageSchema = exports.integerSchema = exports.numberSchema = exports.stringSchema = exports.booleanDefaultToFalseSchema = exports.booleanSchema = void 0;
4
4
  const joi_extensions_1 = require("./joi.extensions");
5
5
  exports.booleanSchema = joi_extensions_1.Joi.boolean();
6
6
  exports.booleanDefaultToFalseSchema = joi_extensions_1.Joi.boolean().default(false);
@@ -10,6 +10,7 @@ exports.integerSchema = joi_extensions_1.Joi.number().integer();
10
10
  exports.percentageSchema = joi_extensions_1.Joi.number().integer().min(0).max(100);
11
11
  exports.dateStringSchema = exports.stringSchema.dateString();
12
12
  exports.binarySchema = joi_extensions_1.Joi.binary();
13
+ exports.dateObjectSchema = joi_extensions_1.Joi.object().instance(Date);
13
14
  const urlSchema = (scheme = 'https') => joi_extensions_1.Joi.string().uri({ scheme });
14
15
  exports.urlSchema = urlSchema;
15
16
  function arraySchema(items) {
@@ -60,7 +61,7 @@ exports.unixTimestampSchema = exports.numberSchema.integer().min(0).max(TS_2500)
60
61
  /**
61
62
  * Between years 2000 and 2050
62
63
  */
63
- exports.unixTimestamp2000Schema = exports.numberSchema.integer().min(0).min(TS_2000).max(TS_2500);
64
+ exports.unixTimestamp2000Schema = exports.numberSchema.integer().min(TS_2000).max(TS_2500);
64
65
  /**
65
66
  * Between years 1970 and 2050
66
67
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "12.83.0",
3
+ "version": "12.85.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -49,8 +49,7 @@
49
49
  "prettier": "^2.0.0",
50
50
  "vue-class-component": "^7.2.6",
51
51
  "vuepress": "^1.7.1",
52
- "vuepress-plugin-typescript": "^0.3.1",
53
- "zod": "^3.19.1"
52
+ "vuepress-plugin-typescript": "^0.3.1"
54
53
  },
55
54
  "bin": {
56
55
  "del": "dist/bin/del.js",
@@ -1,4 +1,6 @@
1
+ import { setGlobalStringifyFunction } from '@naturalcycles/js-lib'
1
2
  import type { CommonLogger } from '@naturalcycles/js-lib'
3
+ import { inspectAnyStringifyFn } from '../string/inspectAny'
2
4
 
3
5
  export interface RunScriptOptions {
4
6
  /**
@@ -35,6 +37,8 @@ const { DEBUG_RUN_SCRIPT } = process.env
35
37
  * Set env DEBUG_RUN_SCRIPT for extra debugging.
36
38
  */
37
39
  export function runScript(fn: (...args: any[]) => any, opt: RunScriptOptions = {}): void {
40
+ setGlobalStringifyFunction(inspectAnyStringifyFn)
41
+
38
42
  const { logger = console, noExit } = opt
39
43
 
40
44
  process.on('uncaughtException', err => {
@@ -17,6 +17,7 @@ export const integerSchema = Joi.number().integer()
17
17
  export const percentageSchema = Joi.number().integer().min(0).max(100)
18
18
  export const dateStringSchema = stringSchema.dateString()
19
19
  export const binarySchema = Joi.binary()
20
+ export const dateObjectSchema = Joi.object().instance(Date)
20
21
 
21
22
  export const urlSchema = (scheme: string | string[] = 'https'): StringSchemaTyped =>
22
23
  Joi.string().uri({ scheme })
@@ -81,7 +82,7 @@ export const unixTimestampSchema = numberSchema.integer().min(0).max(TS_2500)
81
82
  /**
82
83
  * Between years 2000 and 2050
83
84
  */
84
- export const unixTimestamp2000Schema = numberSchema.integer().min(0).min(TS_2000).max(TS_2500)
85
+ export const unixTimestamp2000Schema = numberSchema.integer().min(TS_2000).max(TS_2500)
85
86
  /**
86
87
  * Between years 1970 and 2050
87
88
  */