@ykdz/template 0.0.37 → 0.0.40

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.
Files changed (225) hide show
  1. package/dist/application.d.ts +1 -52
  2. package/dist/application.js +0 -81
  3. package/dist/cli.js +14 -28
  4. package/dist/input-schemas.d.ts +30 -0
  5. package/dist/input-schemas.js +75 -0
  6. package/dist/main.d.ts +3 -14
  7. package/dist/main.js +496 -378
  8. package/dist/result-schemas.d.ts +222 -0
  9. package/dist/result-schemas.js +74 -0
  10. package/dist/standard-schema.d.ts +3 -0
  11. package/dist/standard-schema.js +29 -0
  12. package/node_modules/@standard-schema/spec/LICENSE +21 -0
  13. package/node_modules/@standard-schema/spec/README.md +198 -0
  14. package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
  15. package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
  16. package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
  17. package/node_modules/@standard-schema/spec/dist/index.js +0 -0
  18. package/node_modules/@standard-schema/spec/package.json +52 -0
  19. package/node_modules/@types/node/LICENSE +21 -0
  20. package/node_modules/@types/node/README.md +15 -0
  21. package/node_modules/@types/node/assert/strict.d.ts +111 -0
  22. package/node_modules/@types/node/assert.d.ts +1115 -0
  23. package/node_modules/@types/node/async_hooks.d.ts +619 -0
  24. package/node_modules/@types/node/buffer.buffer.d.ts +477 -0
  25. package/node_modules/@types/node/buffer.d.ts +1941 -0
  26. package/node_modules/@types/node/child_process.d.ts +1480 -0
  27. package/node_modules/@types/node/cluster.d.ts +578 -0
  28. package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  29. package/node_modules/@types/node/console.d.ts +453 -0
  30. package/node_modules/@types/node/constants.d.ts +21 -0
  31. package/node_modules/@types/node/crypto.d.ts +5484 -0
  32. package/node_modules/@types/node/dgram.d.ts +715 -0
  33. package/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
  34. package/node_modules/@types/node/dns/promises.d.ts +503 -0
  35. package/node_modules/@types/node/dns.d.ts +923 -0
  36. package/node_modules/@types/node/domain.d.ts +166 -0
  37. package/node_modules/@types/node/events.d.ts +967 -0
  38. package/node_modules/@types/node/fs/promises.d.ts +1354 -0
  39. package/node_modules/@types/node/fs.d.ts +4777 -0
  40. package/node_modules/@types/node/globals.d.ts +170 -0
  41. package/node_modules/@types/node/globals.typedarray.d.ts +41 -0
  42. package/node_modules/@types/node/http.d.ts +2246 -0
  43. package/node_modules/@types/node/http2.d.ts +2882 -0
  44. package/node_modules/@types/node/https.d.ts +585 -0
  45. package/node_modules/@types/node/index.d.ts +101 -0
  46. package/node_modules/@types/node/inspector.d.ts +323 -0
  47. package/node_modules/@types/node/inspector.generated.d.ts +4406 -0
  48. package/node_modules/@types/node/module.d.ts +844 -0
  49. package/node_modules/@types/node/net.d.ts +1197 -0
  50. package/node_modules/@types/node/os.d.ts +507 -0
  51. package/node_modules/@types/node/package.json +140 -0
  52. package/node_modules/@types/node/path.d.ts +200 -0
  53. package/node_modules/@types/node/perf_hooks.d.ts +1054 -0
  54. package/node_modules/@types/node/process.d.ts +2101 -0
  55. package/node_modules/@types/node/punycode.d.ts +117 -0
  56. package/node_modules/@types/node/querystring.d.ts +152 -0
  57. package/node_modules/@types/node/readline/promises.d.ts +161 -0
  58. package/node_modules/@types/node/readline.d.ts +600 -0
  59. package/node_modules/@types/node/repl.d.ts +438 -0
  60. package/node_modules/@types/node/sea.d.ts +162 -0
  61. package/node_modules/@types/node/sqlite.d.ts +1182 -0
  62. package/node_modules/@types/node/stream/consumers.d.ts +45 -0
  63. package/node_modules/@types/node/stream/promises.d.ts +90 -0
  64. package/node_modules/@types/node/stream/web.d.ts +596 -0
  65. package/node_modules/@types/node/stream.d.ts +1707 -0
  66. package/node_modules/@types/node/string_decoder.d.ts +67 -0
  67. package/node_modules/@types/node/test.d.ts +2656 -0
  68. package/node_modules/@types/node/timers/promises.d.ts +108 -0
  69. package/node_modules/@types/node/timers.d.ts +285 -0
  70. package/node_modules/@types/node/tls.d.ts +1314 -0
  71. package/node_modules/@types/node/trace_events.d.ts +197 -0
  72. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +473 -0
  73. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  74. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  75. package/node_modules/@types/node/ts5.6/index.d.ts +103 -0
  76. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  77. package/node_modules/@types/node/ts5.7/index.d.ts +103 -0
  78. package/node_modules/@types/node/tty.d.ts +209 -0
  79. package/node_modules/@types/node/url.d.ts +1103 -0
  80. package/node_modules/@types/node/util.d.ts +2376 -0
  81. package/node_modules/@types/node/v8.d.ts +1010 -0
  82. package/node_modules/@types/node/vm.d.ts +1160 -0
  83. package/node_modules/@types/node/wasi.d.ts +202 -0
  84. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  85. package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  86. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  87. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  88. package/node_modules/@types/node/web-globals/fetch.d.ts +62 -0
  89. package/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  90. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  91. package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  92. package/node_modules/@types/node/worker_threads.d.ts +894 -0
  93. package/node_modules/@types/node/zlib.d.ts +768 -0
  94. package/node_modules/@valibot/to-json-schema/LICENSE.md +9 -0
  95. package/node_modules/@valibot/to-json-schema/README.md +475 -0
  96. package/node_modules/@valibot/to-json-schema/dist/index.cjs +800 -0
  97. package/node_modules/@valibot/to-json-schema/dist/index.d.cts +991 -0
  98. package/node_modules/@valibot/to-json-schema/dist/index.d.mts +991 -0
  99. package/node_modules/@valibot/to-json-schema/dist/index.min.cjs +1 -0
  100. package/node_modules/@valibot/to-json-schema/dist/index.min.mjs +1 -0
  101. package/node_modules/@valibot/to-json-schema/dist/index.mjs +795 -0
  102. package/node_modules/@valibot/to-json-schema/package.json +75 -0
  103. package/node_modules/@ykdz/cli-contract/LICENSE +21 -0
  104. package/node_modules/@ykdz/cli-contract/dist/atomic-variant-compiler.d.ts +17 -0
  105. package/node_modules/@ykdz/cli-contract/dist/atomic-variant-compiler.js +55 -0
  106. package/node_modules/@ykdz/cli-contract/dist/cli-contract.d.ts +1164 -0
  107. package/node_modules/@ykdz/cli-contract/dist/cli-contract.js +1408 -0
  108. package/node_modules/@ykdz/cli-contract/dist/cli-execution.d.ts +54 -0
  109. package/node_modules/@ykdz/cli-contract/dist/cli-execution.js +708 -0
  110. package/node_modules/@ykdz/cli-contract/dist/cli-invocation.d.ts +174 -0
  111. package/node_modules/@ykdz/cli-contract/dist/cli-invocation.js +524 -0
  112. package/node_modules/@ykdz/cli-contract/dist/cli-write-error.d.ts +10 -0
  113. package/node_modules/@ykdz/cli-contract/dist/cli-write-error.js +14 -0
  114. package/node_modules/@ykdz/cli-contract/dist/contract-definition-error.d.ts +260 -0
  115. package/node_modules/@ykdz/cli-contract/dist/contract-definition-error.js +130 -0
  116. package/node_modules/@ykdz/cli-contract/dist/contract-execution-error.d.ts +63 -0
  117. package/node_modules/@ykdz/cli-contract/dist/contract-execution-error.js +17 -0
  118. package/node_modules/@ykdz/cli-contract/dist/contract-schema-compiler.d.ts +6 -0
  119. package/node_modules/@ykdz/cli-contract/dist/contract-schema-compiler.js +532 -0
  120. package/node_modules/@ykdz/cli-contract/dist/contract-schema.d.ts +14 -0
  121. package/node_modules/@ykdz/cli-contract/dist/contract-schema.js +1 -0
  122. package/node_modules/@ykdz/cli-contract/dist/description.d.ts +2 -0
  123. package/node_modules/@ykdz/cli-contract/dist/description.js +13 -0
  124. package/node_modules/@ykdz/cli-contract/dist/index.d.ts +8 -0
  125. package/node_modules/@ykdz/cli-contract/dist/index.js +7 -0
  126. package/node_modules/@ykdz/cli-contract/dist/json-value.d.ts +4 -0
  127. package/node_modules/@ykdz/cli-contract/dist/json-value.js +64 -0
  128. package/node_modules/@ykdz/cli-contract/dist/node.d.ts +21 -0
  129. package/node_modules/@ykdz/cli-contract/dist/node.js +109 -0
  130. package/node_modules/@ykdz/cli-contract/dist/outcome-fact.d.ts +162 -0
  131. package/node_modules/@ykdz/cli-contract/dist/outcome-fact.js +113 -0
  132. package/node_modules/@ykdz/cli-contract/dist/outcome-wire.d.ts +53 -0
  133. package/node_modules/@ykdz/cli-contract/dist/outcome-wire.js +189 -0
  134. package/node_modules/@ykdz/cli-contract/dist/stream-variant-compiler.d.ts +16 -0
  135. package/node_modules/@ykdz/cli-contract/dist/stream-variant-compiler.js +45 -0
  136. package/node_modules/@ykdz/cli-contract/package.json +69 -0
  137. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.d.ts +20 -0
  138. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.js +27 -28
  139. package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.d.ts +19 -0
  140. package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.js +1 -1
  141. package/node_modules/@ykdz/template-builtin-presets/dist/src/index.d.ts +2 -1
  142. package/node_modules/@ykdz/template-builtin-presets/dist/src/index.js +2 -1
  143. package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-cli/definition.js +9 -5
  144. package/node_modules/@ykdz/template-builtin-presets/dist/src/vike-app/definition.js +0 -4
  145. package/node_modules/@ykdz/template-builtin-presets/package.json +2 -1
  146. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/AGENTS.md.template +10 -4
  147. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/devcontainer.json +3 -0
  148. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/artifact.ts +128 -59
  149. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/handoff.ts +80 -8
  150. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/readiness.ts +7 -3
  151. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/cli.ts +9 -19
  152. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/main.ts +144 -60
  153. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/standard-schema.ts +37 -0
  154. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/journeys/lookup.journey.ts +71 -0
  155. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/integration/command.test.ts +118 -59
  156. package/node_modules/@ykdz/template-core/dist/package-contribution.d.ts +0 -1
  157. package/node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml +2 -1
  158. package/node_modules/@ykdz/template-core/dist/project-blueprint.d.ts +15 -0
  159. package/node_modules/@ykdz/template-core/dist/project-blueprint.js +1 -1
  160. package/node_modules/@ykdz/template-core/dist/project-github.d.ts +1 -1
  161. package/node_modules/undici-types/LICENSE +21 -0
  162. package/node_modules/undici-types/README.md +6 -0
  163. package/node_modules/undici-types/agent.d.ts +32 -0
  164. package/node_modules/undici-types/api.d.ts +43 -0
  165. package/node_modules/undici-types/balanced-pool.d.ts +30 -0
  166. package/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  167. package/node_modules/undici-types/cache.d.ts +36 -0
  168. package/node_modules/undici-types/client-stats.d.ts +15 -0
  169. package/node_modules/undici-types/client.d.ts +123 -0
  170. package/node_modules/undici-types/connector.d.ts +36 -0
  171. package/node_modules/undici-types/content-type.d.ts +21 -0
  172. package/node_modules/undici-types/cookies.d.ts +30 -0
  173. package/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  174. package/node_modules/undici-types/dispatcher.d.ts +279 -0
  175. package/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  176. package/node_modules/undici-types/errors.d.ts +177 -0
  177. package/node_modules/undici-types/eventsource.d.ts +66 -0
  178. package/node_modules/undici-types/fetch.d.ts +211 -0
  179. package/node_modules/undici-types/formdata.d.ts +108 -0
  180. package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  181. package/node_modules/undici-types/global-origin.d.ts +7 -0
  182. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  183. package/node_modules/undici-types/handlers.d.ts +15 -0
  184. package/node_modules/undici-types/header.d.ts +160 -0
  185. package/node_modules/undici-types/index.d.ts +91 -0
  186. package/node_modules/undici-types/interceptors.d.ts +80 -0
  187. package/node_modules/undici-types/mock-agent.d.ts +68 -0
  188. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  189. package/node_modules/undici-types/mock-client.d.ts +27 -0
  190. package/node_modules/undici-types/mock-errors.d.ts +12 -0
  191. package/node_modules/undici-types/mock-interceptor.d.ts +94 -0
  192. package/node_modules/undici-types/mock-pool.d.ts +27 -0
  193. package/node_modules/undici-types/package.json +55 -0
  194. package/node_modules/undici-types/patch.d.ts +29 -0
  195. package/node_modules/undici-types/pool-stats.d.ts +19 -0
  196. package/node_modules/undici-types/pool.d.ts +41 -0
  197. package/node_modules/undici-types/proxy-agent.d.ts +29 -0
  198. package/node_modules/undici-types/readable.d.ts +68 -0
  199. package/node_modules/undici-types/retry-agent.d.ts +8 -0
  200. package/node_modules/undici-types/retry-handler.d.ts +125 -0
  201. package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  202. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  203. package/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  204. package/node_modules/undici-types/util.d.ts +18 -0
  205. package/node_modules/undici-types/utility.d.ts +7 -0
  206. package/node_modules/undici-types/webidl.d.ts +347 -0
  207. package/node_modules/undici-types/websocket.d.ts +188 -0
  208. package/package.json +5 -3
  209. package/dist/command-result.d.ts +0 -9
  210. package/dist/command-result.js +0 -231
  211. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/journeys/greet.journey.ts +0 -46
  212. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/unit/greet.test.ts +0 -15
  213. package/node_modules/@ykdz/template-builtin-presets/templates/vike-app/devcontainer/docker-client.Dockerfile +0 -3
  214. package/node_modules/commander/LICENSE +0 -22
  215. package/node_modules/commander/Readme.md +0 -1172
  216. package/node_modules/commander/index.js +0 -21
  217. package/node_modules/commander/lib/argument.js +0 -147
  218. package/node_modules/commander/lib/command.js +0 -2790
  219. package/node_modules/commander/lib/error.js +0 -36
  220. package/node_modules/commander/lib/help.js +0 -731
  221. package/node_modules/commander/lib/option.js +0 -377
  222. package/node_modules/commander/lib/suggestSimilar.js +0 -99
  223. package/node_modules/commander/package-support.json +0 -19
  224. package/node_modules/commander/package.json +0 -64
  225. package/node_modules/commander/typings/index.d.ts +0 -1113
@@ -0,0 +1,619 @@
1
+ /**
2
+ * We strongly discourage the use of the `async_hooks` API.
3
+ * Other APIs that can cover most of its use cases include:
4
+ *
5
+ * * [`AsyncLocalStorage`](https://nodejs.org/docs/latest-v24.x/api/async_context.html#class-asynclocalstorage) tracks async context
6
+ * * [`process.getActiveResourcesInfo()`](https://nodejs.org/docs/latest-v24.x/api/process.html#processgetactiveresourcesinfo) tracks active resources
7
+ *
8
+ * The `node:async_hooks` module provides an API to track asynchronous resources.
9
+ * It can be accessed using:
10
+ *
11
+ * ```js
12
+ * import async_hooks from 'node:async_hooks';
13
+ * ```
14
+ * @experimental
15
+ * @see [source](https://github.com/nodejs/node/blob/v24.x/lib/async_hooks.js)
16
+ */
17
+ declare module "async_hooks" {
18
+ /**
19
+ * ```js
20
+ * import { executionAsyncId } from 'node:async_hooks';
21
+ * import fs from 'node:fs';
22
+ *
23
+ * console.log(executionAsyncId()); // 1 - bootstrap
24
+ * const path = '.';
25
+ * fs.open(path, 'r', (err, fd) => {
26
+ * console.log(executionAsyncId()); // 6 - open()
27
+ * });
28
+ * ```
29
+ *
30
+ * The ID returned from `executionAsyncId()` is related to execution timing, not
31
+ * causality (which is covered by `triggerAsyncId()`):
32
+ *
33
+ * ```js
34
+ * const server = net.createServer((conn) => {
35
+ * // Returns the ID of the server, not of the new connection, because the
36
+ * // callback runs in the execution scope of the server's MakeCallback().
37
+ * async_hooks.executionAsyncId();
38
+ *
39
+ * }).listen(port, () => {
40
+ * // Returns the ID of a TickObject (process.nextTick()) because all
41
+ * // callbacks passed to .listen() are wrapped in a nextTick().
42
+ * async_hooks.executionAsyncId();
43
+ * });
44
+ * ```
45
+ *
46
+ * Promise contexts may not get precise `executionAsyncIds` by default.
47
+ * See the section on [promise execution tracking](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#promise-execution-tracking).
48
+ * @since v8.1.0
49
+ * @return The `asyncId` of the current execution context. Useful to track when something calls.
50
+ */
51
+ function executionAsyncId(): number;
52
+ /**
53
+ * Resource objects returned by `executionAsyncResource()` are most often internal
54
+ * Node.js handle objects with undocumented APIs. Using any functions or properties
55
+ * on the object is likely to crash your application and should be avoided.
56
+ *
57
+ * Using `executionAsyncResource()` in the top-level execution context will
58
+ * return an empty object as there is no handle or request object to use,
59
+ * but having an object representing the top-level can be helpful.
60
+ *
61
+ * ```js
62
+ * import { open } from 'node:fs';
63
+ * import { executionAsyncId, executionAsyncResource } from 'node:async_hooks';
64
+ *
65
+ * console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
66
+ * open(new URL(import.meta.url), 'r', (err, fd) => {
67
+ * console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
68
+ * });
69
+ * ```
70
+ *
71
+ * This can be used to implement continuation local storage without the
72
+ * use of a tracking `Map` to store the metadata:
73
+ *
74
+ * ```js
75
+ * import { createServer } from 'node:http';
76
+ * import {
77
+ * executionAsyncId,
78
+ * executionAsyncResource,
79
+ * createHook,
80
+ * } from 'node:async_hooks';
81
+ * const sym = Symbol('state'); // Private symbol to avoid pollution
82
+ *
83
+ * createHook({
84
+ * init(asyncId, type, triggerAsyncId, resource) {
85
+ * const cr = executionAsyncResource();
86
+ * if (cr) {
87
+ * resource[sym] = cr[sym];
88
+ * }
89
+ * },
90
+ * }).enable();
91
+ *
92
+ * const server = createServer((req, res) => {
93
+ * executionAsyncResource()[sym] = { state: req.url };
94
+ * setTimeout(function() {
95
+ * res.end(JSON.stringify(executionAsyncResource()[sym]));
96
+ * }, 100);
97
+ * }).listen(3000);
98
+ * ```
99
+ * @since v13.9.0, v12.17.0
100
+ * @return The resource representing the current execution. Useful to store data within the resource.
101
+ */
102
+ function executionAsyncResource(): object;
103
+ /**
104
+ * ```js
105
+ * const server = net.createServer((conn) => {
106
+ * // The resource that caused (or triggered) this callback to be called
107
+ * // was that of the new connection. Thus the return value of triggerAsyncId()
108
+ * // is the asyncId of "conn".
109
+ * async_hooks.triggerAsyncId();
110
+ *
111
+ * }).listen(port, () => {
112
+ * // Even though all callbacks passed to .listen() are wrapped in a nextTick()
113
+ * // the callback itself exists because the call to the server's .listen()
114
+ * // was made. So the return value would be the ID of the server.
115
+ * async_hooks.triggerAsyncId();
116
+ * });
117
+ * ```
118
+ *
119
+ * Promise contexts may not get valid `triggerAsyncId`s by default. See
120
+ * the section on [promise execution tracking](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#promise-execution-tracking).
121
+ * @return The ID of the resource responsible for calling the callback that is currently being executed.
122
+ */
123
+ function triggerAsyncId(): number;
124
+ interface HookCallbacks {
125
+ /**
126
+ * The [`init` callback](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#initasyncid-type-triggerasyncid-resource).
127
+ */
128
+ init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
129
+ /**
130
+ * The [`before` callback](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#beforeasyncid).
131
+ */
132
+ before?(asyncId: number): void;
133
+ /**
134
+ * The [`after` callback](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#afterasyncid).
135
+ */
136
+ after?(asyncId: number): void;
137
+ /**
138
+ * The [`promiseResolve` callback](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#promiseresolveasyncid).
139
+ */
140
+ promiseResolve?(asyncId: number): void;
141
+ /**
142
+ * The [`destroy` callback](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#destroyasyncid).
143
+ */
144
+ destroy?(asyncId: number): void;
145
+ /**
146
+ * Whether the hook should track `Promise`s. Cannot be `false` if
147
+ * `promiseResolve` is set.
148
+ * @default true
149
+ */
150
+ trackPromises?: boolean | undefined;
151
+ }
152
+ interface AsyncHook {
153
+ /**
154
+ * Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
155
+ */
156
+ enable(): this;
157
+ /**
158
+ * Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
159
+ */
160
+ disable(): this;
161
+ }
162
+ /**
163
+ * Registers functions to be called for different lifetime events of each async
164
+ * operation.
165
+ *
166
+ * The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
167
+ * respective asynchronous event during a resource's lifetime.
168
+ *
169
+ * All callbacks are optional. For example, if only resource cleanup needs to
170
+ * be tracked, then only the `destroy` callback needs to be passed. The
171
+ * specifics of all functions that can be passed to `callbacks` is in the
172
+ * [Hook Callbacks](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#hook-callbacks) section.
173
+ *
174
+ * ```js
175
+ * import { createHook } from 'node:async_hooks';
176
+ *
177
+ * const asyncHook = createHook({
178
+ * init(asyncId, type, triggerAsyncId, resource) { },
179
+ * destroy(asyncId) { },
180
+ * });
181
+ * ```
182
+ *
183
+ * The callbacks will be inherited via the prototype chain:
184
+ *
185
+ * ```js
186
+ * class MyAsyncCallbacks {
187
+ * init(asyncId, type, triggerAsyncId, resource) { }
188
+ * destroy(asyncId) {}
189
+ * }
190
+ *
191
+ * class MyAddedCallbacks extends MyAsyncCallbacks {
192
+ * before(asyncId) { }
193
+ * after(asyncId) { }
194
+ * }
195
+ *
196
+ * const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
197
+ * ```
198
+ *
199
+ * Because promises are asynchronous resources whose lifecycle is tracked
200
+ * via the async hooks mechanism, the `init()`, `before()`, `after()`, and
201
+ * `destroy()` callbacks _must not_ be async functions that return promises.
202
+ * @since v8.1.0
203
+ * @param options The [Hook Callbacks](https://nodejs.org/docs/latest-v24.x/api/async_hooks.html#hook-callbacks) to register
204
+ * @returns Instance used for disabling and enabling hooks
205
+ */
206
+ function createHook(options: HookCallbacks): AsyncHook;
207
+ interface AsyncResourceOptions {
208
+ /**
209
+ * The ID of the execution context that created this async event.
210
+ * @default executionAsyncId()
211
+ */
212
+ triggerAsyncId?: number | undefined;
213
+ /**
214
+ * Disables automatic `emitDestroy` when the object is garbage collected.
215
+ * This usually does not need to be set (even if `emitDestroy` is called
216
+ * manually), unless the resource's `asyncId` is retrieved and the
217
+ * sensitive API's `emitDestroy` is called with it.
218
+ * @default false
219
+ */
220
+ requireManualDestroy?: boolean | undefined;
221
+ }
222
+ /**
223
+ * The class `AsyncResource` is designed to be extended by the embedder's async
224
+ * resources. Using this, users can easily trigger the lifetime events of their
225
+ * own resources.
226
+ *
227
+ * The `init` hook will trigger when an `AsyncResource` is instantiated.
228
+ *
229
+ * The following is an overview of the `AsyncResource` API.
230
+ *
231
+ * ```js
232
+ * import { AsyncResource, executionAsyncId } from 'node:async_hooks';
233
+ *
234
+ * // AsyncResource() is meant to be extended. Instantiating a
235
+ * // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
236
+ * // async_hook.executionAsyncId() is used.
237
+ * const asyncResource = new AsyncResource(
238
+ * type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false },
239
+ * );
240
+ *
241
+ * // Run a function in the execution context of the resource. This will
242
+ * // * establish the context of the resource
243
+ * // * trigger the AsyncHooks before callbacks
244
+ * // * call the provided function `fn` with the supplied arguments
245
+ * // * trigger the AsyncHooks after callbacks
246
+ * // * restore the original execution context
247
+ * asyncResource.runInAsyncScope(fn, thisArg, ...args);
248
+ *
249
+ * // Call AsyncHooks destroy callbacks.
250
+ * asyncResource.emitDestroy();
251
+ *
252
+ * // Return the unique ID assigned to the AsyncResource instance.
253
+ * asyncResource.asyncId();
254
+ *
255
+ * // Return the trigger ID for the AsyncResource instance.
256
+ * asyncResource.triggerAsyncId();
257
+ * ```
258
+ */
259
+ class AsyncResource {
260
+ /**
261
+ * AsyncResource() is meant to be extended. Instantiating a
262
+ * new AsyncResource() also triggers init. If triggerAsyncId is omitted then
263
+ * async_hook.executionAsyncId() is used.
264
+ * @param type The type of async event.
265
+ * @param triggerAsyncId The ID of the execution context that created
266
+ * this async event (default: `executionAsyncId()`), or an
267
+ * AsyncResourceOptions object (since v9.3.0)
268
+ */
269
+ constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
270
+ /**
271
+ * Binds the given function to the current execution context.
272
+ * @since v14.8.0, v12.19.0
273
+ * @param fn The function to bind to the current execution context.
274
+ * @param type An optional name to associate with the underlying `AsyncResource`.
275
+ */
276
+ static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
277
+ fn: Func,
278
+ type?: string,
279
+ thisArg?: ThisArg,
280
+ ): Func;
281
+ /**
282
+ * Binds the given function to execute to this `AsyncResource`'s scope.
283
+ * @since v14.8.0, v12.19.0
284
+ * @param fn The function to bind to the current `AsyncResource`.
285
+ */
286
+ bind<Func extends (...args: any[]) => any>(fn: Func): Func;
287
+ /**
288
+ * Call the provided function with the provided arguments in the execution context
289
+ * of the async resource. This will establish the context, trigger the AsyncHooks
290
+ * before callbacks, call the function, trigger the AsyncHooks after callbacks, and
291
+ * then restore the original execution context.
292
+ * @since v9.6.0
293
+ * @param fn The function to call in the execution context of this async resource.
294
+ * @param thisArg The receiver to be used for the function call.
295
+ * @param args Optional arguments to pass to the function.
296
+ */
297
+ runInAsyncScope<This, Result>(
298
+ fn: (this: This, ...args: any[]) => Result,
299
+ thisArg?: This,
300
+ ...args: any[]
301
+ ): Result;
302
+ /**
303
+ * Call all `destroy` hooks. This should only ever be called once. An error will
304
+ * be thrown if it is called more than once. This **must** be manually called. If
305
+ * the resource is left to be collected by the GC then the `destroy` hooks will
306
+ * never be called.
307
+ * @return A reference to `asyncResource`.
308
+ */
309
+ emitDestroy(): this;
310
+ /**
311
+ * @return The unique `asyncId` assigned to the resource.
312
+ */
313
+ asyncId(): number;
314
+ /**
315
+ * @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
316
+ */
317
+ triggerAsyncId(): number;
318
+ }
319
+ interface AsyncLocalStorageOptions {
320
+ /**
321
+ * The default value to be used when no store is provided.
322
+ */
323
+ defaultValue?: any;
324
+ /**
325
+ * A name for the `AsyncLocalStorage` value.
326
+ */
327
+ name?: string | undefined;
328
+ }
329
+ /**
330
+ * This class creates stores that stay coherent through asynchronous operations.
331
+ *
332
+ * While you can create your own implementation on top of the `node:async_hooks` module, `AsyncLocalStorage` should be preferred as it is a performant and memory
333
+ * safe implementation that involves significant optimizations that are non-obvious
334
+ * to implement.
335
+ *
336
+ * The following example uses `AsyncLocalStorage` to build a simple logger
337
+ * that assigns IDs to incoming HTTP requests and includes them in messages
338
+ * logged within each request.
339
+ *
340
+ * ```js
341
+ * import http from 'node:http';
342
+ * import { AsyncLocalStorage } from 'node:async_hooks';
343
+ *
344
+ * const asyncLocalStorage = new AsyncLocalStorage();
345
+ *
346
+ * function logWithId(msg) {
347
+ * const id = asyncLocalStorage.getStore();
348
+ * console.log(`${id !== undefined ? id : '-'}:`, msg);
349
+ * }
350
+ *
351
+ * let idSeq = 0;
352
+ * http.createServer((req, res) => {
353
+ * asyncLocalStorage.run(idSeq++, () => {
354
+ * logWithId('start');
355
+ * // Imagine any chain of async operations here
356
+ * setImmediate(() => {
357
+ * logWithId('finish');
358
+ * res.end();
359
+ * });
360
+ * });
361
+ * }).listen(8080);
362
+ *
363
+ * http.get('http://localhost:8080');
364
+ * http.get('http://localhost:8080');
365
+ * // Prints:
366
+ * // 0: start
367
+ * // 0: finish
368
+ * // 1: start
369
+ * // 1: finish
370
+ * ```
371
+ *
372
+ * Each instance of `AsyncLocalStorage` maintains an independent storage context.
373
+ * Multiple instances can safely exist simultaneously without risk of interfering
374
+ * with each other's data.
375
+ * @since v13.10.0, v12.17.0
376
+ */
377
+ class AsyncLocalStorage<T> {
378
+ /**
379
+ * Creates a new instance of `AsyncLocalStorage`. Store is only provided within a
380
+ * `run()` call or after an `enterWith()` call.
381
+ */
382
+ constructor(options?: AsyncLocalStorageOptions);
383
+ /**
384
+ * Binds the given function to the current execution context.
385
+ * @since v19.8.0
386
+ * @param fn The function to bind to the current execution context.
387
+ * @return A new function that calls `fn` within the captured execution context.
388
+ */
389
+ static bind<Func extends (...args: any[]) => any>(fn: Func): Func;
390
+ /**
391
+ * Captures the current execution context and returns a function that accepts a
392
+ * function as an argument. Whenever the returned function is called, it
393
+ * calls the function passed to it within the captured context.
394
+ *
395
+ * ```js
396
+ * const asyncLocalStorage = new AsyncLocalStorage();
397
+ * const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot());
398
+ * const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore()));
399
+ * console.log(result); // returns 123
400
+ * ```
401
+ *
402
+ * AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple
403
+ * async context tracking purposes, for example:
404
+ *
405
+ * ```js
406
+ * class Foo {
407
+ * #runInAsyncScope = AsyncLocalStorage.snapshot();
408
+ *
409
+ * get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); }
410
+ * }
411
+ *
412
+ * const foo = asyncLocalStorage.run(123, () => new Foo());
413
+ * console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123
414
+ * ```
415
+ * @since v19.8.0
416
+ * @return A new function with the signature `(fn: (...args) : R, ...args) : R`.
417
+ */
418
+ static snapshot(): <R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R;
419
+ /**
420
+ * Disables the instance of `AsyncLocalStorage`. All subsequent calls
421
+ * to `asyncLocalStorage.getStore()` will return `undefined` until `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
422
+ *
423
+ * When calling `asyncLocalStorage.disable()`, all current contexts linked to the
424
+ * instance will be exited.
425
+ *
426
+ * Calling `asyncLocalStorage.disable()` is required before the `asyncLocalStorage` can be garbage collected. This does not apply to stores
427
+ * provided by the `asyncLocalStorage`, as those objects are garbage collected
428
+ * along with the corresponding async resources.
429
+ *
430
+ * Use this method when the `asyncLocalStorage` is not in use anymore
431
+ * in the current process.
432
+ * @since v13.10.0, v12.17.0
433
+ * @experimental
434
+ */
435
+ disable(): void;
436
+ /**
437
+ * Returns the current store.
438
+ * If called outside of an asynchronous context initialized by
439
+ * calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
440
+ * returns `undefined`.
441
+ * @since v13.10.0, v12.17.0
442
+ */
443
+ getStore(): T | undefined;
444
+ /**
445
+ * The name of the `AsyncLocalStorage` instance if provided.
446
+ * @since v24.0.0
447
+ */
448
+ readonly name: string;
449
+ /**
450
+ * Runs a function synchronously within a context and returns its
451
+ * return value. The store is not accessible outside of the callback function.
452
+ * The store is accessible to any asynchronous operations created within the
453
+ * callback.
454
+ *
455
+ * The optional `args` are passed to the callback function.
456
+ *
457
+ * If the callback function throws an error, the error is thrown by `run()` too.
458
+ * The stacktrace is not impacted by this call and the context is exited.
459
+ *
460
+ * Example:
461
+ *
462
+ * ```js
463
+ * const store = { id: 2 };
464
+ * try {
465
+ * asyncLocalStorage.run(store, () => {
466
+ * asyncLocalStorage.getStore(); // Returns the store object
467
+ * setTimeout(() => {
468
+ * asyncLocalStorage.getStore(); // Returns the store object
469
+ * }, 200);
470
+ * throw new Error();
471
+ * });
472
+ * } catch (e) {
473
+ * asyncLocalStorage.getStore(); // Returns undefined
474
+ * // The error will be caught here
475
+ * }
476
+ * ```
477
+ * @since v13.10.0, v12.17.0
478
+ */
479
+ run<R>(store: T, callback: () => R): R;
480
+ run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
481
+ /**
482
+ * Runs a function synchronously outside of a context and returns its
483
+ * return value. The store is not accessible within the callback function or
484
+ * the asynchronous operations created within the callback. Any `getStore()` call done within the callback function will always return `undefined`.
485
+ *
486
+ * The optional `args` are passed to the callback function.
487
+ *
488
+ * If the callback function throws an error, the error is thrown by `exit()` too.
489
+ * The stacktrace is not impacted by this call and the context is re-entered.
490
+ *
491
+ * Example:
492
+ *
493
+ * ```js
494
+ * // Within a call to run
495
+ * try {
496
+ * asyncLocalStorage.getStore(); // Returns the store object or value
497
+ * asyncLocalStorage.exit(() => {
498
+ * asyncLocalStorage.getStore(); // Returns undefined
499
+ * throw new Error();
500
+ * });
501
+ * } catch (e) {
502
+ * asyncLocalStorage.getStore(); // Returns the same object or value
503
+ * // The error will be caught here
504
+ * }
505
+ * ```
506
+ * @since v13.10.0, v12.17.0
507
+ * @experimental
508
+ */
509
+ exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
510
+ /**
511
+ * Transitions into the context for the remainder of the current
512
+ * synchronous execution and then persists the store through any following
513
+ * asynchronous calls.
514
+ *
515
+ * Example:
516
+ *
517
+ * ```js
518
+ * const store = { id: 1 };
519
+ * // Replaces previous store with the given store object
520
+ * asyncLocalStorage.enterWith(store);
521
+ * asyncLocalStorage.getStore(); // Returns the store object
522
+ * someAsyncOperation(() => {
523
+ * asyncLocalStorage.getStore(); // Returns the same object
524
+ * });
525
+ * ```
526
+ *
527
+ * This transition will continue for the _entire_ synchronous execution.
528
+ * This means that if, for example, the context is entered within an event
529
+ * handler subsequent event handlers will also run within that context unless
530
+ * specifically bound to another context with an `AsyncResource`. That is why `run()` should be preferred over `enterWith()` unless there are strong reasons
531
+ * to use the latter method.
532
+ *
533
+ * ```js
534
+ * const store = { id: 1 };
535
+ *
536
+ * emitter.on('my-event', () => {
537
+ * asyncLocalStorage.enterWith(store);
538
+ * });
539
+ * emitter.on('my-event', () => {
540
+ * asyncLocalStorage.getStore(); // Returns the same object
541
+ * });
542
+ *
543
+ * asyncLocalStorage.getStore(); // Returns undefined
544
+ * emitter.emit('my-event');
545
+ * asyncLocalStorage.getStore(); // Returns the same object
546
+ * ```
547
+ * @since v13.11.0, v12.17.0
548
+ * @experimental
549
+ */
550
+ enterWith(store: T): void;
551
+ }
552
+ /**
553
+ * @since v17.2.0, v16.14.0
554
+ * @return A map of provider types to the corresponding numeric id.
555
+ * This map contains all the event types that might be emitted by the `async_hooks.init()` event.
556
+ */
557
+ namespace asyncWrapProviders {
558
+ const NONE: number;
559
+ const DIRHANDLE: number;
560
+ const DNSCHANNEL: number;
561
+ const ELDHISTOGRAM: number;
562
+ const FILEHANDLE: number;
563
+ const FILEHANDLECLOSEREQ: number;
564
+ const FIXEDSIZEBLOBCOPY: number;
565
+ const FSEVENTWRAP: number;
566
+ const FSREQCALLBACK: number;
567
+ const FSREQPROMISE: number;
568
+ const GETADDRINFOREQWRAP: number;
569
+ const GETNAMEINFOREQWRAP: number;
570
+ const HEAPSNAPSHOT: number;
571
+ const HTTP2SESSION: number;
572
+ const HTTP2STREAM: number;
573
+ const HTTP2PING: number;
574
+ const HTTP2SETTINGS: number;
575
+ const HTTPINCOMINGMESSAGE: number;
576
+ const HTTPCLIENTREQUEST: number;
577
+ const JSSTREAM: number;
578
+ const JSUDPWRAP: number;
579
+ const MESSAGEPORT: number;
580
+ const PIPECONNECTWRAP: number;
581
+ const PIPESERVERWRAP: number;
582
+ const PIPEWRAP: number;
583
+ const PROCESSWRAP: number;
584
+ const PROMISE: number;
585
+ const QUERYWRAP: number;
586
+ const SHUTDOWNWRAP: number;
587
+ const SIGNALWRAP: number;
588
+ const STATWATCHER: number;
589
+ const STREAMPIPE: number;
590
+ const TCPCONNECTWRAP: number;
591
+ const TCPSERVERWRAP: number;
592
+ const TCPWRAP: number;
593
+ const TTYWRAP: number;
594
+ const UDPSENDWRAP: number;
595
+ const UDPWRAP: number;
596
+ const SIGINTWATCHDOG: number;
597
+ const WORKER: number;
598
+ const WORKERHEAPSNAPSHOT: number;
599
+ const WRITEWRAP: number;
600
+ const ZLIB: number;
601
+ const CHECKPRIMEREQUEST: number;
602
+ const PBKDF2REQUEST: number;
603
+ const KEYPAIRGENREQUEST: number;
604
+ const KEYGENREQUEST: number;
605
+ const KEYEXPORTREQUEST: number;
606
+ const CIPHERREQUEST: number;
607
+ const DERIVEBITSREQUEST: number;
608
+ const HASHREQUEST: number;
609
+ const RANDOMBYTESREQUEST: number;
610
+ const RANDOMPRIMEREQUEST: number;
611
+ const SCRYPTREQUEST: number;
612
+ const SIGNREQUEST: number;
613
+ const TLSWRAP: number;
614
+ const VERIFYREQUEST: number;
615
+ }
616
+ }
617
+ declare module "node:async_hooks" {
618
+ export * from "async_hooks";
619
+ }