build(deps-dev): apply updates
[poolifier.git] / src / utility-types.ts
index 3d5673f93111d552a4cdce0364d7c036cf3e175e..c7663606cf86afe67f84d6f25d831d567b5bab3f 100644 (file)
@@ -1,6 +1,8 @@
+import type { AsyncResource } from 'node:async_hooks'
 import type { EventLoopUtilization } from 'node:perf_hooks'
 import type { MessagePort, TransferListItem } from 'node:worker_threads'
-import type { KillBehavior } from './worker/worker-options'
+
+import type { KillBehavior } from './worker/worker-options.js'
 
 /**
  * Worker error.
@@ -69,10 +71,6 @@ export interface WorkerStatistics {
  * @internal
  */
 export interface Task<Data = unknown> {
-  /**
-   * Worker id.
-   */
-  readonly workerId: number
   /**
    * Task name.
    */
@@ -104,6 +102,10 @@ export interface Task<Data = unknown> {
  */
 export interface MessageValue<Data = unknown, ErrorData = unknown>
   extends Task<Data> {
+  /**
+   * Worker id.
+   */
+  readonly workerId?: number
   /**
    * Kill code.
    */
@@ -119,7 +121,7 @@ export interface MessageValue<Data = unknown, ErrorData = unknown>
   /**
    * Task function operation:
    * - `'add'` - Add a task function.
-   * - `'delete'` - Delete a task function.
+   * - `'remove'` - Remove a task function.
    * - `'default'` - Set a task function as default.
    */
   readonly taskFunctionOperation?: 'add' | 'remove' | 'default'
@@ -176,6 +178,10 @@ export interface PromiseResponseWrapper<Response = unknown> {
    * The worker node key executing the task.
    */
   readonly workerNodeKey: number
+  /**
+   * The asynchronous resource used to track the task execution.
+   */
+  readonly asyncResource?: AsyncResource
 }
 
 export type Writable<T> = { -readonly [P in keyof T]: T[P] }