@naturalcycles/nodejs-lib 12.73.0 → 12.75.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/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,7 +32,7 @@ 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.globby)(patterns, {
36
36
  dot: true,
37
37
  expandDirectories: true,
38
38
  onlyFiles: true,
@@ -44,7 +44,7 @@ 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.globby)(patterns, {
48
48
  dot: true,
49
49
  expandDirectories: true,
50
50
  onlyDirectories: true,
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.globby)(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.globby.sync(opt.inputPatterns, {
43
43
  cwd: opt.baseDir,
44
44
  dot: opt.dotfiles,
45
45
  });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import Ajv from 'ajv';
2
+ import * as fastGlob from 'fast-glob';
3
+ import { Options as FastGlobOptions } from 'fast-glob';
4
+ import * as globby from 'globby';
5
+ import { GlobbyOptions } from 'globby';
2
6
  import { RequestError, TimeoutError } from 'got';
3
7
  import type { AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Got } from 'got';
4
8
  import { AnySchema, ValidationErrorItem } from 'joi';
@@ -67,5 +71,5 @@ export * from './validation/joi/joi.shared.schemas';
67
71
  import { JoiValidationError, JoiValidationErrorData } from './validation/joi/joi.validation.error';
68
72
  import { convert, getValidationResult, isValid, JoiValidationResult, undefinedIfInvalid, validate } from './validation/joi/joi.validation.util';
69
73
  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, };
74
+ export type { GlobbyOptions, 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, };
75
+ export { globby, 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,13 @@
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 = exports.globby = 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;
9
+ const globby = require("globby");
10
+ exports.globby = globby;
7
11
  const got_1 = require("got");
8
12
  Object.defineProperty(exports, "RequestError", { enumerable: true, get: function () { return got_1.RequestError; } });
9
13
  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
  /**
@@ -38,6 +38,8 @@ function getAjv(opt) {
38
38
  return ajv;
39
39
  }
40
40
  exports.getAjv = getAjv;
41
+ const TS_2500 = 16725225600; // 2500-01-01
42
+ const TS_2000 = 946684800; // 2000-01-01
41
43
  function addCustomAjvFormats(ajv) {
42
44
  return (ajv
43
45
  .addFormat('id', /^[a-z0-9_]{6,64}$/)
@@ -50,15 +52,25 @@ function addCustomAjvFormats(ajv) {
50
52
  .addFormat('unixTimestamp', {
51
53
  type: 'number',
52
54
  validate: (n) => {
53
- // 16725225600 is 2500-01-01 in seconds
54
- return n >= 0 && n < 16725225600;
55
+ return n >= 0 && n < TS_2500;
56
+ },
57
+ })
58
+ .addFormat('unixTimestamp2000', {
59
+ type: 'number',
60
+ validate: (n) => {
61
+ return n >= TS_2000 && n < TS_2500;
55
62
  },
56
63
  })
57
64
  .addFormat('unixTimestampMillis', {
58
65
  type: 'number',
59
66
  validate: (n) => {
60
- // 16725225600000 is 2500-01-01 in milliseconds
61
- return n >= 0 && n < 16725225600000;
67
+ return n >= 0 && n < TS_2500 * 1000;
68
+ },
69
+ })
70
+ .addFormat('unixTimestampMillis2000', {
71
+ type: 'number',
72
+ validate: (n) => {
73
+ return n >= TS_2000 * 1000 && n < TS_2500 * 1000;
62
74
  },
63
75
  })
64
76
  .addFormat('utcOffset', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "12.73.0",
3
+ "version": "12.75.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -26,6 +26,7 @@
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
31
  "globby": "^11.0.0",
31
32
  "got": "^11.0.1",
@@ -38,8 +39,8 @@
38
39
  },
39
40
  "devDependencies": {
40
41
  "@naturalcycles/bench-lib": "^1.0.7",
41
- "@naturalcycles/dev-lib": "^12.0.0",
42
- "@types/node": "^17.0.0",
42
+ "@naturalcycles/dev-lib": "^13.0.0",
43
+ "@types/node": "^18.0.0",
43
44
  "@types/yargs": "^16.0.0",
44
45
  "jest": "^28.0.3",
45
46
  "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 { globby } from '../index'
5
5
 
6
6
  export interface DelOptions {
7
7
  /**
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 { globby } from '../index'
8
8
 
9
9
  /**
10
10
  * Everything defaults to `undefined`.
package/src/index.ts CHANGED
@@ -1,4 +1,8 @@
1
1
  import Ajv from 'ajv'
2
+ import * as fastGlob from 'fast-glob'
3
+ import { Options as FastGlobOptions } from 'fast-glob'
4
+ import * as globby from 'globby'
5
+ import { GlobbyOptions } from 'globby'
2
6
  import { RequestError, TimeoutError } from 'got'
3
7
  import type { AfterResponseHook, BeforeErrorHook, BeforeRequestHook, Got } from 'got'
4
8
  import { AnySchema, ValidationErrorItem } from 'joi'
@@ -111,6 +115,8 @@ import {
111
115
  import { runScript, RunScriptOptions } from './script'
112
116
 
113
117
  export type {
118
+ GlobbyOptions,
119
+ FastGlobOptions,
114
120
  RunScriptOptions,
115
121
  JoiValidationErrorData,
116
122
  JoiValidationResult,
@@ -159,6 +165,8 @@ export type {
159
165
  }
160
166
 
161
167
  export {
168
+ globby,
169
+ fastGlob,
162
170
  JoiValidationError,
163
171
  validate,
164
172
  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,
@@ -43,6 +43,9 @@ export function getAjv(opt?: Options): Ajv {
43
43
  return ajv
44
44
  }
45
45
 
46
+ const TS_2500 = 16725225600 // 2500-01-01
47
+ const TS_2000 = 946684800 // 2000-01-01
48
+
46
49
  function addCustomAjvFormats(ajv: Ajv): Ajv {
47
50
  return (
48
51
  ajv
@@ -56,15 +59,25 @@ function addCustomAjvFormats(ajv: Ajv): Ajv {
56
59
  .addFormat('unixTimestamp', {
57
60
  type: 'number',
58
61
  validate: (n: number) => {
59
- // 16725225600 is 2500-01-01 in seconds
60
- return n >= 0 && n < 16725225600
62
+ return n >= 0 && n < TS_2500
63
+ },
64
+ })
65
+ .addFormat('unixTimestamp2000', {
66
+ type: 'number',
67
+ validate: (n: number) => {
68
+ return n >= TS_2000 && n < TS_2500
61
69
  },
62
70
  })
63
71
  .addFormat('unixTimestampMillis', {
64
72
  type: 'number',
65
73
  validate: (n: number) => {
66
- // 16725225600000 is 2500-01-01 in milliseconds
67
- return n >= 0 && n < 16725225600000
74
+ return n >= 0 && n < TS_2500 * 1000
75
+ },
76
+ })
77
+ .addFormat('unixTimestampMillis2000', {
78
+ type: 'number',
79
+ validate: (n: number) => {
80
+ return n >= TS_2000 * 1000 && n < TS_2500 * 1000
68
81
  },
69
82
  })
70
83
  .addFormat('utcOffset', {