@naturalcycles/nodejs-lib 15.100.0 → 15.102.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,5 +1,5 @@
1
1
  import os from 'node:os';
2
- import { pDelay } from '@naturalcycles/js-lib/promise/pDelay.js';
2
+ import { AsyncManager } from '@naturalcycles/js-lib';
3
3
  import { setGlobalStringifyFunction } from '@naturalcycles/js-lib/string/stringify.js';
4
4
  import { dimGrey } from '../colors/colors.js';
5
5
  import { loadEnvFileIfExists } from '../node.util.js';
@@ -45,9 +45,10 @@ export function runScript(fn, opt = {}) {
45
45
  void (async () => {
46
46
  try {
47
47
  await fn();
48
- await pDelay(); // to ensure all async operations are completed
49
48
  if (DEBUG_RUN_SCRIPT)
50
49
  logger.log(`runScript promise resolved`);
50
+ // to ensure all async operations are completed (with a timeout)
51
+ await AsyncManager.allDone(600_000);
51
52
  if (!noExit) {
52
53
  setImmediate(() => process.exit(0));
53
54
  }
@@ -336,11 +336,11 @@ export declare class JObject<OUT extends AnyObject, Opt extends boolean = false>
336
336
  * When set, the validation will not strip away properties that are not specified explicitly in the schema.
337
337
  */
338
338
  allowAdditionalProperties(): this;
339
- extend<P extends Record<string, JSchema<any, any>>>(props: P): JObject<Override<OUT, {
339
+ extend<P extends Record<string, JSchema<any, any>>>(props: P): JObject<Expand<Override<OUT, {
340
340
  [K in keyof P as P[K] extends JSchema<any, infer IsOpt> ? IsOpt extends true ? never : K : never]: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never;
341
341
  } & {
342
342
  [K in keyof P as P[K] extends JSchema<any, infer IsOpt> ? IsOpt extends true ? K : never : never]?: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never;
343
- }>, false>;
343
+ }>>, false>;
344
344
  /**
345
345
  * Concatenates another schema to the current schema.
346
346
  *
@@ -352,11 +352,11 @@ export declare class JObject<OUT extends AnyObject, Opt extends boolean = false>
352
352
  /**
353
353
  * Extends the current schema with `id`, `created` and `updated` according to NC DB conventions.
354
354
  */
355
- dbEntity(): JObject<Override<OUT, {
355
+ dbEntity(): JObject<Expand<Override<OUT, {
356
356
  id: string;
357
357
  created: UnixTimestamp;
358
358
  updated: UnixTimestamp;
359
- } & {}>, false>;
359
+ } & {}>>, false>;
360
360
  minProperties(minProperties: number): this;
361
361
  maxProperties(maxProperties: number): this;
362
362
  exclusiveProperties(propNames: readonly (keyof OUT & string)[]): this;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.100.0",
4
+ "version": "15.102.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@standard-schema/spec": "^1",
@@ -1,6 +1,6 @@
1
1
  import os from 'node:os'
2
+ import { AsyncManager } from '@naturalcycles/js-lib'
2
3
  import type { CommonLogger } from '@naturalcycles/js-lib/log'
3
- import { pDelay } from '@naturalcycles/js-lib/promise/pDelay.js'
4
4
  import { setGlobalStringifyFunction } from '@naturalcycles/js-lib/string/stringify.js'
5
5
  import type { AnyObject } from '@naturalcycles/js-lib/types'
6
6
  import { dimGrey } from '../colors/colors.js'
@@ -76,10 +76,11 @@ export function runScript(fn: (...args: any[]) => any, opt: RunScriptOptions = {
76
76
  try {
77
77
  await fn()
78
78
 
79
- await pDelay() // to ensure all async operations are completed
80
-
81
79
  if (DEBUG_RUN_SCRIPT) logger.log(`runScript promise resolved`)
82
80
 
81
+ // to ensure all async operations are completed (with a timeout)
82
+ await AsyncManager.allDone(600_000)
83
+
83
84
  if (!noExit) {
84
85
  setImmediate(() => process.exit(0))
85
86
  }
@@ -1071,23 +1071,25 @@ export class JObject<OUT extends AnyObject, Opt extends boolean = false> extends
1071
1071
  extend<P extends Record<string, JSchema<any, any>>>(
1072
1072
  props: P,
1073
1073
  ): JObject<
1074
- Override<
1075
- OUT,
1076
- {
1077
- // required keys
1078
- [K in keyof P as P[K] extends JSchema<any, infer IsOpt>
1079
- ? IsOpt extends true
1080
- ? never
1081
- : K
1082
- : never]: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never
1083
- } & {
1084
- // optional keys
1085
- [K in keyof P as P[K] extends JSchema<any, infer IsOpt>
1086
- ? IsOpt extends true
1087
- ? K
1088
- : never
1089
- : never]?: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never
1090
- }
1074
+ Expand<
1075
+ Override<
1076
+ OUT,
1077
+ {
1078
+ // required keys
1079
+ [K in keyof P as P[K] extends JSchema<any, infer IsOpt>
1080
+ ? IsOpt extends true
1081
+ ? never
1082
+ : K
1083
+ : never]: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never
1084
+ } & {
1085
+ // optional keys
1086
+ [K in keyof P as P[K] extends JSchema<any, infer IsOpt>
1087
+ ? IsOpt extends true
1088
+ ? K
1089
+ : never
1090
+ : never]?: P[K] extends JSchema<infer OUT2, any> ? OUT2 : never
1091
+ }
1092
+ >
1091
1093
  >,
1092
1094
  false
1093
1095
  > {