@naturalcycles/nodejs-lib 12.74.0 → 12.75.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.
package/dist/fs/del.js CHANGED
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.del = void 0;
4
4
  const js_lib_1 = require("@naturalcycles/js-lib");
5
5
  const fs = require("fs-extra");
6
- const globby = require("globby");
7
6
  const colors_1 = require("../colors");
7
+ const index_1 = require("../index");
8
8
  const DEF_OPT = {
9
9
  patterns: [],
10
10
  concurrency: Number.POSITIVE_INFINITY,
@@ -32,9 +32,9 @@ async function del(_opt) {
32
32
  console.log(opt);
33
33
  }
34
34
  // 1. glob only files, expand dirs, delete
35
- const filenames = await globby(patterns, {
35
+ const filenames = await (0, index_1.fastGlob)(patterns, {
36
36
  dot: true,
37
- expandDirectories: true,
37
+ // expandDirectories: true,
38
38
  onlyFiles: true,
39
39
  });
40
40
  if (verbose || debug || dry) {
@@ -44,9 +44,9 @@ async function del(_opt) {
44
44
  return;
45
45
  await (0, js_lib_1.pMap)(filenames, filepath => fs.remove(filepath), { concurrency });
46
46
  // 2. glob only dirs, expand, delete only empty!
47
- let dirnames = await globby(patterns, {
47
+ let dirnames = await (0, index_1.fastGlob)(patterns, {
48
48
  dot: true,
49
- expandDirectories: true,
49
+ // expandDirectories: true,
50
50
  onlyDirectories: true,
51
51
  });
52
52
  // Add original patterns (if any of them are dirs)
package/dist/fs/kpy.js CHANGED
@@ -5,13 +5,13 @@ const path = require("path");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const cpFile = require("cp-file");
7
7
  const fs = require("fs-extra");
8
- const globby = require("globby");
9
8
  const moveFile = require("move-file");
10
9
  const colors_1 = require("../colors");
10
+ const index_1 = require("../index");
11
11
  async function kpy(opt) {
12
12
  const started = Date.now();
13
13
  kpyPrepare(opt);
14
- const filenames = await globby(opt.inputPatterns, {
14
+ const filenames = await (0, index_1.fastGlob)(opt.inputPatterns, {
15
15
  cwd: opt.baseDir,
16
16
  dot: opt.dotfiles,
17
17
  });
@@ -39,7 +39,7 @@ exports.kpy = kpy;
39
39
  function kpySync(opt) {
40
40
  const started = Date.now();
41
41
  kpyPrepare(opt);
42
- const filenames = globby.sync(opt.inputPatterns, {
42
+ const filenames = index_1.fastGlob.sync(opt.inputPatterns, {
43
43
  cwd: opt.baseDir,
44
44
  dot: opt.dotfiles,
45
45
  });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import Ajv from 'ajv';
2
+ import * as fastGlob from 'fast-glob';
3
+ import { Options as FastGlobOptions } from 'fast-glob';
2
4
  import { RequestError, TimeoutError } from 'got';
3
5
  import type { AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Got } from 'got';
4
6
  import { AnySchema, ValidationErrorItem } from 'joi';
@@ -67,5 +69,5 @@ export * from './validation/joi/joi.shared.schemas';
67
69
  import { JoiValidationError, JoiValidationErrorData } from './validation/joi/joi.validation.error';
68
70
  import { convert, getValidationResult, isValid, JoiValidationResult, undefinedIfInvalid, validate } from './validation/joi/joi.validation.util';
69
71
  import { runScript, RunScriptOptions } from './script';
70
- export type { RunScriptOptions, JoiValidationErrorData, JoiValidationResult, ValidationErrorItem, ExtendedJoi, SchemaTyped, AnySchema, AnySchemaTyped, ArraySchemaTyped, BooleanSchemaTyped, NumberSchemaTyped, ObjectSchemaTyped, StringSchemaTyped, IDebug, IDebugger, SlackServiceCfg, SlackMessage, SlackMessageProps, SlackApiBody, SlackMessagePrefixHook, ReadableTyped, WritableTyped, TransformTyped, PipelineFromNDJsonFileOptions, PipelineToNDJsonFileOptions, TransformJsonParseOptions, TransformToNDJsonOptions, TransformMapOptions, TransformMapSyncOptions, NDJSONStreamForEachOptions, TransformOptions, TransformMultiThreadedOptions, WorkerClassInterface, WorkerInput, WorkerOutput, TableDiffOptions, InspectAnyOptions, Got, GetGotOptions, AfterResponseHook, BeforeErrorHook, BeforeRequestHook, AjvValidationOptions, AjvSchemaCfg, AjvValidationErrorData, };
71
- export { JoiValidationError, validate, getValidationResult, isValid, undefinedIfInvalid, convert, Joi, Debug, SlackService, slackDefaultMessagePrefixHook, ndjsonStreamForEach, pipelineFromNDJsonFile, pipelineToNDJsonFile, NDJsonStats, streamToNDJsonFile, transformJsonParse, bufferReviver, transformToNDJson, transformMap, transformMapSync, transformMultiThreaded, BaseWorkerClass, tableDiff, inspectAny, inspectAnyStringifyFn, RequestError, TimeoutError, _chunkBuffer, Ajv, AjvSchema, AjvValidationError, readJsonSchemas, readAjvSchemas, runScript, };
72
+ export type { FastGlobOptions, RunScriptOptions, JoiValidationErrorData, JoiValidationResult, ValidationErrorItem, ExtendedJoi, SchemaTyped, AnySchema, AnySchemaTyped, ArraySchemaTyped, BooleanSchemaTyped, NumberSchemaTyped, ObjectSchemaTyped, StringSchemaTyped, IDebug, IDebugger, SlackServiceCfg, SlackMessage, SlackMessageProps, SlackApiBody, SlackMessagePrefixHook, ReadableTyped, WritableTyped, TransformTyped, PipelineFromNDJsonFileOptions, PipelineToNDJsonFileOptions, TransformJsonParseOptions, TransformToNDJsonOptions, TransformMapOptions, TransformMapSyncOptions, NDJSONStreamForEachOptions, TransformOptions, TransformMultiThreadedOptions, WorkerClassInterface, WorkerInput, WorkerOutput, TableDiffOptions, InspectAnyOptions, Got, GetGotOptions, AfterResponseHook, BeforeErrorHook, BeforeRequestHook, AjvValidationOptions, AjvSchemaCfg, AjvValidationErrorData, };
73
+ export { fastGlob, JoiValidationError, validate, getValidationResult, isValid, undefinedIfInvalid, convert, Joi, Debug, SlackService, slackDefaultMessagePrefixHook, ndjsonStreamForEach, pipelineFromNDJsonFile, pipelineToNDJsonFile, NDJsonStats, streamToNDJsonFile, transformJsonParse, bufferReviver, transformToNDJson, transformMap, transformMapSync, transformMultiThreaded, BaseWorkerClass, tableDiff, inspectAny, inspectAnyStringifyFn, RequestError, TimeoutError, _chunkBuffer, Ajv, AjvSchema, AjvValidationError, readJsonSchemas, readAjvSchemas, runScript, };
package/dist/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runScript = exports.readAjvSchemas = exports.readJsonSchemas = exports.AjvValidationError = exports.AjvSchema = exports.Ajv = exports._chunkBuffer = exports.TimeoutError = exports.RequestError = exports.inspectAnyStringifyFn = exports.inspectAny = exports.tableDiff = exports.BaseWorkerClass = exports.transformMultiThreaded = exports.transformMapSync = exports.transformMap = exports.transformToNDJson = exports.bufferReviver = exports.transformJsonParse = exports.streamToNDJsonFile = exports.NDJsonStats = exports.pipelineToNDJsonFile = exports.pipelineFromNDJsonFile = exports.ndjsonStreamForEach = exports.slackDefaultMessagePrefixHook = exports.SlackService = exports.Debug = exports.Joi = exports.convert = exports.undefinedIfInvalid = exports.isValid = exports.getValidationResult = exports.validate = exports.JoiValidationError = void 0;
3
+ exports.runScript = exports.readAjvSchemas = exports.readJsonSchemas = exports.AjvValidationError = exports.AjvSchema = exports.Ajv = exports._chunkBuffer = exports.TimeoutError = exports.RequestError = exports.inspectAnyStringifyFn = exports.inspectAny = exports.tableDiff = exports.BaseWorkerClass = exports.transformMultiThreaded = exports.transformMapSync = exports.transformMap = exports.transformToNDJson = exports.bufferReviver = exports.transformJsonParse = exports.streamToNDJsonFile = exports.NDJsonStats = exports.pipelineToNDJsonFile = exports.pipelineFromNDJsonFile = exports.ndjsonStreamForEach = exports.slackDefaultMessagePrefixHook = exports.SlackService = exports.Debug = exports.Joi = exports.convert = exports.undefinedIfInvalid = exports.isValid = exports.getValidationResult = exports.validate = exports.JoiValidationError = exports.fastGlob = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const ajv_1 = require("ajv");
6
6
  exports.Ajv = ajv_1.default;
7
+ const fastGlob = require("fast-glob");
8
+ exports.fastGlob = fastGlob;
7
9
  const got_1 = require("got");
8
10
  Object.defineProperty(exports, "RequestError", { enumerable: true, get: function () { return got_1.RequestError; } });
9
11
  Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return got_1.TimeoutError; } });
@@ -4,8 +4,8 @@ exports.secretsDecrypt = void 0;
4
4
  const path = require("path");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const fs = require("fs-extra");
7
- const globby = require("globby");
8
7
  const colors_1 = require("../colors");
8
+ const index_1 = require("../index");
9
9
  const crypto_util_1 = require("../security/crypto.util");
10
10
  // Debug it like this:
11
11
  // yarn tsn ./src/bin/secrets-decrypt.ts --file ./src/test/secrets2.json --jsonMode --encKey MPd/30v0Zcce4I5mfwF4NSXrpTYD9OO4/fIqw6rjNiWp2b1GN9Xm8nQZqr7c9kKSsATqtwe0HkJFDUGzDSow44GDgDICgB1u1rGa5eNqtxnOVGRR+lIinCvN/1OnpjzeoJy2bStXPj1DKx8anMqgA8SoOZdlWRNSkEeZlolru8Ey0ujZo22dfwMyRIEniLcqvBm/iMiAkV82fn/TxYw05GarAoJcrfPeDBvuOXsARnMCyX18qTFL0iojxeTU8JHxr8TX3eXDq9cJJmridEKlwRIAzADwtetI4ttlP8lwJj1pmgsBIN3iqYssZYCkZ3HMV6BoEc7LTI5z/45rKrAT1A==
@@ -17,7 +17,7 @@ const crypto_util_1 = require("../security/crypto.util");
17
17
  function secretsDecrypt(dir, file, encKey, del = false, jsonMode = false) {
18
18
  // If `file` is provided - only this one file is used
19
19
  const patterns = file ? [file] : dir.map(d => `${d}/**/*.enc`);
20
- const filenames = globby.sync(patterns);
20
+ const filenames = index_1.fastGlob.sync(patterns);
21
21
  filenames.forEach(filename => {
22
22
  let plainFilename;
23
23
  if (jsonMode) {
@@ -4,8 +4,8 @@ exports.secretsEncrypt = void 0;
4
4
  const path = require("path");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const fs = require("fs-extra");
7
- const globby = require("globby");
8
7
  const colors_1 = require("../colors");
8
+ const index_1 = require("../index");
9
9
  const crypto_util_1 = require("../security/crypto.util");
10
10
  /**
11
11
  * Encrypts all files in given directory (except *.enc), saves encrypted versions as filename.ext.enc.
@@ -18,7 +18,7 @@ function secretsEncrypt(pattern, file, encKey, del = false, jsonMode = false) {
18
18
  ...pattern,
19
19
  `!**/*.enc`, // excluding already encoded
20
20
  ];
21
- const filenames = globby.sync(patterns);
21
+ const filenames = index_1.fastGlob.sync(patterns);
22
22
  let encFilename;
23
23
  filenames.forEach(filename => {
24
24
  if (jsonMode) {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requireFileToExist = exports.requireEnvKeys = void 0;
4
+ const fs = require("fs");
4
5
  require("dotenv/config"); // ensure .env is read before requiring keys
5
- const fs = require("fs-extra");
6
6
  /**
7
7
  * @example
8
8
  *
@@ -22,7 +22,7 @@ function requireEnvKeys(...keys) {
22
22
  }
23
23
  exports.requireEnvKeys = requireEnvKeys;
24
24
  function requireFileToExist(filePath) {
25
- if (!fs.pathExistsSync(filePath)) {
25
+ if (!fs.existsSync(filePath)) {
26
26
  throw new Error(`Required file should exist: ${filePath}`);
27
27
  }
28
28
  }
@@ -1,5 +1,5 @@
1
1
  import { JsonSchema } from '@naturalcycles/js-lib';
2
- import { GlobbyOptions } from 'globby';
2
+ import type { FastGlobOptions } from '../..';
3
3
  import { AjvSchema, AjvSchemaCfg } from './ajvSchema';
4
4
  /**
5
5
  * Does fs.readFileSync + JSON.parse for ALL files matching the passed `glob` pattern.
@@ -9,7 +9,7 @@ import { AjvSchema, AjvSchemaCfg } from './ajvSchema';
9
9
  *
10
10
  * @experimental
11
11
  */
12
- export declare function readJsonSchemas(patterns: string | string[], opt?: GlobbyOptions): JsonSchema[];
12
+ export declare function readJsonSchemas(patterns: string | string[], opt?: FastGlobOptions): JsonSchema[];
13
13
  /**
14
14
  * Reads json schemas from given dir (glob pattern).
15
15
  * Creates new AjvSchema for each of them (ajv validates them upon creation).
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readAjvSchemas = exports.readJsonSchemas = void 0;
4
4
  const fs = require("fs");
5
- const globby = require("globby");
5
+ const __1 = require("../..");
6
6
  const ajvSchema_1 = require("./ajvSchema");
7
7
  /**
8
8
  * Does fs.readFileSync + JSON.parse for ALL files matching the passed `glob` pattern.
@@ -13,7 +13,7 @@ const ajvSchema_1 = require("./ajvSchema");
13
13
  * @experimental
14
14
  */
15
15
  function readJsonSchemas(patterns, opt) {
16
- return globby.sync(patterns, opt).map(fileName => JSON.parse(fs.readFileSync(fileName, 'utf8')));
16
+ return __1.fastGlob.sync(patterns, opt).map(fileName => JSON.parse(fs.readFileSync(fileName, 'utf8')));
17
17
  }
18
18
  exports.readJsonSchemas = readJsonSchemas;
19
19
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "12.74.0",
3
+ "version": "12.75.0",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -26,8 +26,8 @@
26
26
  "debug": "^4.1.1",
27
27
  "dotenv": "^16.0.0",
28
28
  "execa": "^5.0.0",
29
+ "fast-glob": "^3.2.11",
29
30
  "fs-extra": "^10.0.0",
30
- "globby": "^11.0.0",
31
31
  "got": "^11.0.1",
32
32
  "joi": "17.4.2",
33
33
  "lru-cache": "^7.4.0",
@@ -38,8 +38,8 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@naturalcycles/bench-lib": "^1.0.7",
41
- "@naturalcycles/dev-lib": "^12.0.0",
42
- "@types/node": "^17.0.0",
41
+ "@naturalcycles/dev-lib": "^13.0.0",
42
+ "@types/node": "^18.0.0",
43
43
  "@types/yargs": "^16.0.0",
44
44
  "jest": "^28.0.3",
45
45
  "nock": "^13.0.2",
package/src/fs/del.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { pFilter, pMap, _since } from '@naturalcycles/js-lib'
2
2
  import * as fs from 'fs-extra'
3
- import * as globby from 'globby'
4
3
  import { dimGrey, yellow } from '../colors'
4
+ import { fastGlob } from '../index'
5
5
 
6
6
  export interface DelOptions {
7
7
  /**
@@ -58,9 +58,9 @@ export async function del(_opt: DelOptions | DelSingleOption): Promise<void> {
58
58
 
59
59
  // 1. glob only files, expand dirs, delete
60
60
 
61
- const filenames = await globby(patterns, {
61
+ const filenames = await fastGlob(patterns, {
62
62
  dot: true,
63
- expandDirectories: true,
63
+ // expandDirectories: true,
64
64
  onlyFiles: true,
65
65
  })
66
66
 
@@ -73,9 +73,9 @@ export async function del(_opt: DelOptions | DelSingleOption): Promise<void> {
73
73
  await pMap(filenames, filepath => fs.remove(filepath), { concurrency })
74
74
 
75
75
  // 2. glob only dirs, expand, delete only empty!
76
- let dirnames = await globby(patterns, {
76
+ let dirnames = await fastGlob(patterns, {
77
77
  dot: true,
78
- expandDirectories: true,
78
+ // expandDirectories: true,
79
79
  onlyDirectories: true,
80
80
  })
81
81
 
package/src/fs/kpy.ts CHANGED
@@ -2,9 +2,9 @@ import * as path from 'path'
2
2
  import { _since } from '@naturalcycles/js-lib'
3
3
  import * as cpFile from 'cp-file'
4
4
  import * as fs from 'fs-extra'
5
- import * as globby from 'globby'
6
5
  import * as moveFile from 'move-file'
7
6
  import { boldWhite, dimGrey, grey, yellow } from '../colors'
7
+ import { fastGlob } from '../index'
8
8
 
9
9
  /**
10
10
  * Everything defaults to `undefined`.
@@ -50,7 +50,7 @@ export async function kpy(opt: KpyOptions): Promise<void> {
50
50
 
51
51
  kpyPrepare(opt)
52
52
 
53
- const filenames = await globby(opt.inputPatterns!, {
53
+ const filenames = await fastGlob(opt.inputPatterns!, {
54
54
  cwd: opt.baseDir,
55
55
  dot: opt.dotfiles,
56
56
  })
@@ -87,7 +87,7 @@ export function kpySync(opt: KpyOptions): void {
87
87
 
88
88
  kpyPrepare(opt)
89
89
 
90
- const filenames = globby.sync(opt.inputPatterns!, {
90
+ const filenames = fastGlob.sync(opt.inputPatterns!, {
91
91
  cwd: opt.baseDir,
92
92
  dot: opt.dotfiles,
93
93
  })
package/src/index.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import Ajv from 'ajv'
2
+ import * as fastGlob from 'fast-glob'
3
+ import { Options as FastGlobOptions } from 'fast-glob'
2
4
  import { RequestError, TimeoutError } from 'got'
3
5
  import type { AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Got } from 'got'
4
6
  import { AnySchema, ValidationErrorItem } from 'joi'
@@ -111,6 +113,7 @@ import {
111
113
  import { runScript, RunScriptOptions } from './script'
112
114
 
113
115
  export type {
116
+ FastGlobOptions,
114
117
  RunScriptOptions,
115
118
  JoiValidationErrorData,
116
119
  JoiValidationResult,
@@ -159,6 +162,7 @@ export type {
159
162
  }
160
163
 
161
164
  export {
165
+ fastGlob,
162
166
  JoiValidationError,
163
167
  validate,
164
168
  getValidationResult,
@@ -1,8 +1,8 @@
1
1
  import * as path from 'path'
2
2
  import { _assert } from '@naturalcycles/js-lib'
3
3
  import * as fs from 'fs-extra'
4
- import globby = require('globby')
5
4
  import { dimGrey, yellow } from '../colors'
5
+ import { fastGlob } from '../index'
6
6
  import { decryptObject, decryptRandomIVBuffer } from '../security/crypto.util'
7
7
 
8
8
  export interface DecryptCLIOptions {
@@ -31,7 +31,7 @@ export function secretsDecrypt(
31
31
  // If `file` is provided - only this one file is used
32
32
  const patterns = file ? [file] : dir.map(d => `${d}/**/*.enc`)
33
33
 
34
- const filenames = globby.sync(patterns)
34
+ const filenames = fastGlob.sync(patterns)
35
35
 
36
36
  filenames.forEach(filename => {
37
37
  let plainFilename
@@ -1,8 +1,8 @@
1
1
  import * as path from 'path'
2
2
  import { _assert } from '@naturalcycles/js-lib'
3
3
  import * as fs from 'fs-extra'
4
- import globby = require('globby')
5
4
  import { dimGrey, yellow } from '../colors'
5
+ import { fastGlob } from '../index'
6
6
  import { encryptObject, encryptRandomIVBuffer } from '../security/crypto.util'
7
7
 
8
8
  export interface EncryptCLIOptions {
@@ -30,7 +30,7 @@ export function secretsEncrypt(
30
30
  ...pattern,
31
31
  `!**/*.enc`, // excluding already encoded
32
32
  ]
33
- const filenames = globby.sync(patterns)
33
+ const filenames = fastGlob.sync(patterns)
34
34
  let encFilename
35
35
 
36
36
  filenames.forEach(filename => {
@@ -1,6 +1,6 @@
1
+ import * as fs from 'fs'
1
2
  import type { ValuesOf } from '@naturalcycles/js-lib'
2
3
  import 'dotenv/config' // ensure .env is read before requiring keys
3
- import * as fs from 'fs-extra'
4
4
 
5
5
  /**
6
6
  * @example
@@ -16,13 +16,13 @@ export function requireEnvKeys<T extends readonly string[]>(
16
16
  return keys.reduce((r, k) => {
17
17
  const v = process.env[k]
18
18
  if (!v) throw new Error(`${k} env variable is required, but missing`)
19
- r[k] = v
19
+ r[k as ValuesOf<T>] = v
20
20
  return r
21
21
  }, {} as { [k in ValuesOf<T>]: string })
22
22
  }
23
23
 
24
24
  export function requireFileToExist(filePath: string): void {
25
- if (!fs.pathExistsSync(filePath)) {
25
+ if (!fs.existsSync(filePath)) {
26
26
  throw new Error(`Required file should exist: ${filePath}`)
27
27
  }
28
28
  }
@@ -1,7 +1,7 @@
1
1
  import * as fs from 'fs'
2
2
  import { JsonSchema } from '@naturalcycles/js-lib'
3
- import { GlobbyOptions } from 'globby'
4
- import * as globby from 'globby'
3
+ import { fastGlob } from '../..'
4
+ import type { FastGlobOptions } from '../..'
5
5
  import { AjvSchema, AjvSchemaCfg } from './ajvSchema'
6
6
 
7
7
  /**
@@ -12,8 +12,8 @@ import { AjvSchema, AjvSchemaCfg } from './ajvSchema'
12
12
  *
13
13
  * @experimental
14
14
  */
15
- export function readJsonSchemas(patterns: string | string[], opt?: GlobbyOptions): JsonSchema[] {
16
- return globby.sync(patterns, opt).map(fileName => JSON.parse(fs.readFileSync(fileName, 'utf8')))
15
+ export function readJsonSchemas(patterns: string | string[], opt?: FastGlobOptions): JsonSchema[] {
16
+ return fastGlob.sync(patterns, opt).map(fileName => JSON.parse(fs.readFileSync(fileName, 'utf8')))
17
17
  }
18
18
 
19
19
  /**
@@ -159,7 +159,7 @@ export class AjvSchema<T = unknown> {
159
159
  const errors = this.validateFunction.errors!
160
160
 
161
161
  const {
162
- objectId = _isObject(obj) ? (obj['id'] as string) : undefined,
162
+ objectId = _isObject(obj) ? (obj['id' as keyof T] as any) : undefined,
163
163
  objectName = this.cfg.objectName,
164
164
  logErrors = this.cfg.logErrors,
165
165
  separator = this.cfg.separator,