@naturalcycles/nodejs-lib 15.9.0 → 15.10.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.
@@ -1,6 +1,6 @@
1
1
  import { _isObject, _lazyValue, } from '@naturalcycles/js-lib';
2
2
  import { JsonSchemaAnyBuilder } from '@naturalcycles/js-lib/json-schema';
3
- import { _deepCopy, _filterNullishValues } from '@naturalcycles/js-lib/object';
3
+ import { _filterNullishValues } from '@naturalcycles/js-lib/object';
4
4
  import { _substringBefore } from '@naturalcycles/js-lib/string';
5
5
  import { _inspect } from '../../string/inspect.js';
6
6
  import { AjvValidationError } from './ajvValidationError.js';
@@ -73,7 +73,7 @@ export class AjvSchema {
73
73
  }
74
74
  getValidationResult(input, opt = {}) {
75
75
  const fn = this.getAJVValidateFunction();
76
- const item = opt.mutateInput || typeof input !== 'object' ? input : _deepCopy(input);
76
+ const item = opt.mutateInput || typeof input !== 'object' ? input : structuredClone(input);
77
77
  const valid = fn(item); // mutates item
78
78
  if (valid)
79
79
  return [null, item];
@@ -1,4 +1,4 @@
1
- import type { BaseDBEntity, IANATimezone, IsoDateTime, NumberEnum, StringEnum, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib/types';
1
+ import type { BaseDBEntity, IANATimezone, IsoDate, IsoDateTime, NumberEnum, StringEnum, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib/types';
2
2
  import type { AlternativesSchema, AnySchema, ArraySchema, ObjectSchema } from 'joi';
3
3
  import type { NumberSchema } from './number.extensions.js';
4
4
  import type { StringSchema } from './string.extensions.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.9.0",
4
+ "version": "15.10.1",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@types/js-yaml": "^4",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/through2-concurrent": "^2",
26
- "@naturalcycles/dev-lib": "19.22.0"
26
+ "@naturalcycles/dev-lib": "18.4.2"
27
27
  },
28
28
  "exports": {
29
29
  ".": "./dist/index.js",
@@ -6,7 +6,7 @@ import {
6
6
  } from '@naturalcycles/js-lib'
7
7
  import type { JsonSchema, JsonSchemaBuilder } from '@naturalcycles/js-lib/json-schema'
8
8
  import { JsonSchemaAnyBuilder } from '@naturalcycles/js-lib/json-schema'
9
- import { _deepCopy, _filterNullishValues } from '@naturalcycles/js-lib/object'
9
+ import { _filterNullishValues } from '@naturalcycles/js-lib/object'
10
10
  import { _substringBefore } from '@naturalcycles/js-lib/string'
11
11
  import type { Ajv } from 'ajv'
12
12
  import { _inspect } from '../../string/inspect.js'
@@ -136,7 +136,7 @@ export class AjvSchema<T = unknown> {
136
136
  ): ValidationFunctionResult<T, AjvValidationError> {
137
137
  const fn = this.getAJVValidateFunction()
138
138
 
139
- const item = opt.mutateInput || typeof input !== 'object' ? input : _deepCopy(input)
139
+ const item = opt.mutateInput || typeof input !== 'object' ? input : structuredClone(input)
140
140
 
141
141
  const valid = fn(item) // mutates item
142
142
  if (valid) return [null, item]
@@ -7,6 +7,7 @@ import {
7
7
  import type {
8
8
  BaseDBEntity,
9
9
  IANATimezone,
10
+ IsoDate,
10
11
  IsoDateTime,
11
12
  NumberEnum,
12
13
  StringEnum,
@@ -26,7 +27,7 @@ export const numberSchema = Joi.number()
26
27
  export const numberSchemaTyped = <T>(): NumberSchema<T> => Joi.number<T>()
27
28
  export const integerSchema = Joi.number().integer()
28
29
  export const percentageSchema = Joi.number().integer().min(0).max(100)
29
- export const dateStringSchema = stringSchema.dateString()
30
+ export const dateStringSchema: StringSchema<IsoDate> = stringSchema.dateString()
30
31
  export const binarySchema = Joi.binary()
31
32
  export const dateObjectSchema = Joi.object().instance(Date)
32
33