@struct-ai/sdk 0.2.0 → 0.2.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.
Files changed (190) hide show
  1. package/README.md +46 -3
  2. package/package.json +12 -12
  3. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/content-capture.d.ts +0 -10
  4. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/context.d.ts +0 -30
  5. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/core.d.ts +0 -120
  6. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/events.d.ts +0 -12
  7. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/index.d.ts +0 -6
  8. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/anthropic-content.d.ts +0 -24
  9. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/anthropic.d.ts +0 -34
  10. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/index.d.ts +0 -5
  11. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain-callback.d.ts +0 -134
  12. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain-content.d.ts +0 -35
  13. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/integrations/langchain.d.ts +0 -11
  14. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/package.json +0 -3
  15. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/semconv.d.ts +0 -54
  16. package/dist/node_modules/@struct-ai/sdk/dist/commonjs/truncation.d.ts +0 -10
  17. package/dist/node_modules/@struct-ai/sdk/dist/esm/content-capture.d.ts +0 -10
  18. package/dist/node_modules/@struct-ai/sdk/dist/esm/context.d.ts +0 -30
  19. package/dist/node_modules/@struct-ai/sdk/dist/esm/core.d.ts +0 -120
  20. package/dist/node_modules/@struct-ai/sdk/dist/esm/events.d.ts +0 -12
  21. package/dist/node_modules/@struct-ai/sdk/dist/esm/index.d.ts +0 -6
  22. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/anthropic-content.d.ts +0 -24
  23. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/anthropic.d.ts +0 -34
  24. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/index.d.ts +0 -5
  25. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain-callback.d.ts +0 -134
  26. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain-content.d.ts +0 -35
  27. package/dist/node_modules/@struct-ai/sdk/dist/esm/integrations/langchain.d.ts +0 -11
  28. package/dist/node_modules/@struct-ai/sdk/dist/esm/package.json +0 -3
  29. package/dist/node_modules/@struct-ai/sdk/dist/esm/semconv.d.ts +0 -54
  30. package/dist/node_modules/@struct-ai/sdk/dist/esm/truncation.d.ts +0 -10
  31. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/commonjs/package.json +0 -3
  32. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/esm/package.json +0 -3
  33. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/package.json +0 -103
  34. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/package.json +0 -103
  35. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/package.json +0 -118
  36. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/package.json +0 -916
  37. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/package.json +0 -188
  38. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/openai/package.json +0 -105
  39. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api/package.json +0 -96
  40. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api-logs/package.json +0 -91
  41. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/core/package.json +0 -96
  42. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-logs-otlp-proto/package.json +0 -108
  43. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-trace-otlp-proto/package.json +0 -105
  44. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/resources/package.json +0 -100
  45. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-logs/package.json +0 -109
  46. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-base/package.json +0 -100
  47. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-node/package.json +0 -76
  48. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/package.json +0 -140
  49. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/nock/package.json +0 -89
  50. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/tshy/package.json +0 -81
  51. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/tsx/package.json +0 -68
  52. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/typescript/package.json +0 -120
  53. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/vitest/package.json +0 -239
  54. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/node_modules/zod/package.json +0 -135
  55. package/dist/node_modules/@struct-ai/sdk/dist/node_modules/@struct-ai/sdk/package.json +0 -103
  56. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/core.d.ts +0 -244
  57. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/error.d.ts +0 -54
  58. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/index.d.ts +0 -188
  59. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/package.json +0 -103
  60. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/pagination.d.ts +0 -26
  61. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/resource.d.ts +0 -6
  62. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/streaming.d.ts +0 -41
  63. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/uploads.d.ts +0 -75
  64. package/dist/node_modules/@struct-ai/sdk/node_modules/@anthropic-ai/sdk/version.d.ts +0 -2
  65. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/experimental.d.ts +0 -1
  66. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/index.d.ts +0 -1
  67. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/anthropic/package.json +0 -118
  68. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/agents.d.ts +0 -1
  69. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/caches.d.ts +0 -1
  70. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/chat_history.d.ts +0 -1
  71. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/context.d.ts +0 -1
  72. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/documents.d.ts +0 -1
  73. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/embeddings.d.ts +0 -1
  74. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/example_selectors.d.ts +0 -1
  75. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/index.d.ts +0 -1
  76. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/indexing.d.ts +0 -1
  77. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/load.d.ts +0 -1
  78. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/memory.d.ts +0 -1
  79. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/messages.d.ts +0 -1
  80. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/output_parsers.d.ts +0 -1
  81. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/outputs.d.ts +0 -1
  82. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/package.json +0 -916
  83. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/prompt_values.d.ts +0 -1
  84. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/prompts.d.ts +0 -1
  85. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/retrievers.d.ts +0 -1
  86. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/runnables.d.ts +0 -1
  87. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/singletons.d.ts +0 -1
  88. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/stores.d.ts +0 -1
  89. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/structured_query.d.ts +0 -1
  90. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/tools.d.ts +0 -1
  91. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/core/vectorstores.d.ts +0 -1
  92. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/index.d.ts +0 -1
  93. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/package.json +0 -188
  94. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/prebuilt.d.ts +0 -1
  95. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/pregel.d.ts +0 -1
  96. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/remote.d.ts +0 -1
  97. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/web.d.ts +0 -1
  98. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/langgraph/zod.d.ts +0 -1
  99. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/openai/index.d.ts +0 -1
  100. package/dist/node_modules/@struct-ai/sdk/node_modules/@langchain/openai/package.json +0 -105
  101. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api/package.json +0 -96
  102. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/api-logs/package.json +0 -91
  103. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/core/package.json +0 -96
  104. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-logs-otlp-proto/package.json +0 -108
  105. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/exporter-trace-otlp-proto/package.json +0 -105
  106. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/resources/package.json +0 -100
  107. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-logs/package.json +0 -109
  108. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-base/package.json +0 -100
  109. package/dist/node_modules/@struct-ai/sdk/node_modules/@opentelemetry/sdk-trace-node/package.json +0 -76
  110. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/assert.d.ts +0 -1062
  111. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/async_hooks.d.ts +0 -605
  112. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/buffer.buffer.d.ts +0 -471
  113. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/buffer.d.ts +0 -1936
  114. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/child_process.d.ts +0 -1475
  115. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/cluster.d.ts +0 -577
  116. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/console.d.ts +0 -452
  117. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/constants.d.ts +0 -21
  118. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/crypto.d.ts +0 -4590
  119. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/dgram.d.ts +0 -597
  120. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/diagnostics_channel.d.ts +0 -578
  121. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/dns.d.ts +0 -871
  122. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/domain.d.ts +0 -170
  123. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/events.d.ts +0 -977
  124. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/fs.d.ts +0 -4375
  125. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/globals.d.ts +0 -172
  126. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/globals.typedarray.d.ts +0 -38
  127. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/http.d.ts +0 -2049
  128. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/http2.d.ts +0 -2631
  129. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/https.d.ts +0 -578
  130. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/index.d.ts +0 -93
  131. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/inspector.generated.d.ts +0 -3966
  132. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/module.d.ts +0 -539
  133. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/net.d.ts +0 -1031
  134. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/os.d.ts +0 -506
  135. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/package.json +0 -140
  136. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/path.d.ts +0 -200
  137. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/perf_hooks.d.ts +0 -961
  138. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/process.d.ts +0 -1961
  139. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/punycode.d.ts +0 -117
  140. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/querystring.d.ts +0 -152
  141. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/readline.d.ts +0 -589
  142. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/repl.d.ts +0 -430
  143. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/sea.d.ts +0 -153
  144. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/stream.d.ts +0 -1698
  145. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/string_decoder.d.ts +0 -67
  146. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/test.d.ts +0 -1787
  147. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/timers.d.ts +0 -286
  148. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/tls.d.ts +0 -1259
  149. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/trace_events.d.ts +0 -197
  150. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/tty.d.ts +0 -208
  151. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/url.d.ts +0 -964
  152. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/util.d.ts +0 -2331
  153. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/v8.d.ts +0 -809
  154. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/vm.d.ts +0 -1001
  155. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/wasi.d.ts +0 -181
  156. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/worker_threads.d.ts +0 -715
  157. package/dist/node_modules/@struct-ai/sdk/node_modules/@types/node/zlib.d.ts +0 -598
  158. package/dist/node_modules/@struct-ai/sdk/node_modules/nock/package.json +0 -89
  159. package/dist/node_modules/@struct-ai/sdk/node_modules/tshy/package.json +0 -81
  160. package/dist/node_modules/@struct-ai/sdk/node_modules/tsx/package.json +0 -68
  161. package/dist/node_modules/@struct-ai/sdk/node_modules/typescript/package.json +0 -120
  162. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/config.d.ts +0 -3
  163. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/coverage.d.ts +0 -1
  164. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/environments.d.ts +0 -1
  165. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/globals.d.ts +0 -22
  166. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/import-meta.d.ts +0 -5
  167. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/importMeta.d.ts +0 -4
  168. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/jsdom.d.ts +0 -6
  169. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/mocker.d.ts +0 -1
  170. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/node.d.ts +0 -1
  171. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/optional-runtime-types.d.ts +0 -6
  172. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/optional-types.d.ts +0 -7
  173. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/package.json +0 -239
  174. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/reporters.d.ts +0 -1
  175. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/runners.d.ts +0 -1
  176. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/snapshot.d.ts +0 -1
  177. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/suite.d.ts +0 -1
  178. package/dist/node_modules/@struct-ai/sdk/node_modules/vitest/worker.d.ts +0 -1
  179. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/index.d.ts +0 -4
  180. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/locales/package.json +0 -7
  181. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/mini/package.json +0 -7
  182. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/package.json +0 -135
  183. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v3/package.json +0 -7
  184. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/classic/package.json +0 -7
  185. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/core/package.json +0 -7
  186. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/locales/package.json +0 -7
  187. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/mini/package.json +0 -7
  188. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4/package.json +0 -7
  189. package/dist/node_modules/@struct-ai/sdk/node_modules/zod/v4-mini/package.json +0 -7
  190. package/dist/node_modules/@struct-ai/sdk/package.json +0 -103
@@ -1,286 +0,0 @@
1
- /**
2
- * The `timer` module exposes a global API for scheduling functions to
3
- * be called at some future period of time. Because the timer functions are
4
- * globals, there is no need to import `node:timers` to use the API.
5
- *
6
- * The timer functions within Node.js implement a similar API as the timers API
7
- * provided by Web Browsers but use a different internal implementation that is
8
- * built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout).
9
- * @see [source](https://github.com/nodejs/node/blob/v20.x/lib/timers.js)
10
- */
11
- declare module "timers" {
12
- import { Abortable } from "node:events";
13
- import * as promises from "node:timers/promises";
14
- export interface TimerOptions extends Abortable {
15
- /**
16
- * Set to `false` to indicate that the scheduled `Timeout`
17
- * should not require the Node.js event loop to remain active.
18
- * @default true
19
- */
20
- ref?: boolean | undefined;
21
- }
22
- global {
23
- namespace NodeJS {
24
- /**
25
- * This object is created internally and is returned from `setImmediate()`. It
26
- * can be passed to `clearImmediate()` in order to cancel the scheduled
27
- * actions.
28
- *
29
- * By default, when an immediate is scheduled, the Node.js event loop will continue
30
- * running as long as the immediate is active. The `Immediate` object returned by
31
- * `setImmediate()` exports both `immediate.ref()` and `immediate.unref()`
32
- * functions that can be used to control this default behavior.
33
- */
34
- interface Immediate extends RefCounted, Disposable {
35
- /**
36
- * If true, the `Immediate` object will keep the Node.js event loop active.
37
- * @since v11.0.0
38
- */
39
- hasRef(): boolean;
40
- /**
41
- * When called, requests that the Node.js event loop _not_ exit so long as the
42
- * `Immediate` is active. Calling `immediate.ref()` multiple times will have no
43
- * effect.
44
- *
45
- * By default, all `Immediate` objects are "ref'ed", making it normally unnecessary
46
- * to call `immediate.ref()` unless `immediate.unref()` had been called previously.
47
- * @since v9.7.0
48
- * @returns a reference to `immediate`
49
- */
50
- ref(): this;
51
- /**
52
- * When called, the active `Immediate` object will not require the Node.js event
53
- * loop to remain active. If there is no other activity keeping the event loop
54
- * running, the process may exit before the `Immediate` object's callback is
55
- * invoked. Calling `immediate.unref()` multiple times will have no effect.
56
- * @since v9.7.0
57
- * @returns a reference to `immediate`
58
- */
59
- unref(): this;
60
- /**
61
- * Cancels the immediate. This is similar to calling `clearImmediate()`.
62
- * @since v20.5.0, v18.18.0
63
- * @experimental
64
- */
65
- [Symbol.dispose](): void;
66
- _onImmediate(...args: any[]): void;
67
- }
68
- // Legacy interface used in Node.js v9 and prior
69
- /** @deprecated Use `NodeJS.Timeout` instead. */
70
- interface Timer extends RefCounted {
71
- hasRef(): boolean;
72
- refresh(): this;
73
- [Symbol.toPrimitive](): number;
74
- }
75
- /**
76
- * This object is created internally and is returned from `setTimeout()` and
77
- * `setInterval()`. It can be passed to either `clearTimeout()` or
78
- * `clearInterval()` in order to cancel the scheduled actions.
79
- *
80
- * By default, when a timer is scheduled using either `setTimeout()` or
81
- * `setInterval()`, the Node.js event loop will continue running as long as the
82
- * timer is active. Each of the `Timeout` objects returned by these functions
83
- * export both `timeout.ref()` and `timeout.unref()` functions that can be used to
84
- * control this default behavior.
85
- */
86
- interface Timeout extends RefCounted, Disposable, Timer {
87
- /**
88
- * Cancels the timeout.
89
- * @since v0.9.1
90
- * @legacy Use `clearTimeout()` instead.
91
- * @returns a reference to `timeout`
92
- */
93
- close(): this;
94
- /**
95
- * If true, the `Timeout` object will keep the Node.js event loop active.
96
- * @since v11.0.0
97
- */
98
- hasRef(): boolean;
99
- /**
100
- * When called, requests that the Node.js event loop _not_ exit so long as the
101
- * `Timeout` is active. Calling `timeout.ref()` multiple times will have no effect.
102
- *
103
- * By default, all `Timeout` objects are "ref'ed", making it normally unnecessary
104
- * to call `timeout.ref()` unless `timeout.unref()` had been called previously.
105
- * @since v0.9.1
106
- * @returns a reference to `timeout`
107
- */
108
- ref(): this;
109
- /**
110
- * Sets the timer's start time to the current time, and reschedules the timer to
111
- * call its callback at the previously specified duration adjusted to the current
112
- * time. This is useful for refreshing a timer without allocating a new
113
- * JavaScript object.
114
- *
115
- * Using this on a timer that has already called its callback will reactivate the
116
- * timer.
117
- * @since v10.2.0
118
- * @returns a reference to `timeout`
119
- */
120
- refresh(): this;
121
- /**
122
- * When called, the active `Timeout` object will not require the Node.js event loop
123
- * to remain active. If there is no other activity keeping the event loop running,
124
- * the process may exit before the `Timeout` object's callback is invoked. Calling
125
- * `timeout.unref()` multiple times will have no effect.
126
- * @since v0.9.1
127
- * @returns a reference to `timeout`
128
- */
129
- unref(): this;
130
- /**
131
- * Coerce a `Timeout` to a primitive. The primitive can be used to
132
- * clear the `Timeout`. The primitive can only be used in the
133
- * same thread where the timeout was created. Therefore, to use it
134
- * across `worker_threads` it must first be passed to the correct
135
- * thread. This allows enhanced compatibility with browser
136
- * `setTimeout()` and `setInterval()` implementations.
137
- * @since v14.9.0, v12.19.0
138
- */
139
- [Symbol.toPrimitive](): number;
140
- /**
141
- * Cancels the timeout.
142
- * @since v20.5.0, v18.18.0
143
- * @experimental
144
- */
145
- [Symbol.dispose](): void;
146
- _onTimeout(...args: any[]): void;
147
- }
148
- }
149
- /**
150
- * Schedules the "immediate" execution of the `callback` after I/O events'
151
- * callbacks.
152
- *
153
- * When multiple calls to `setImmediate()` are made, the `callback` functions are
154
- * queued for execution in the order in which they are created. The entire callback
155
- * queue is processed every event loop iteration. If an immediate timer is queued
156
- * from inside an executing callback, that timer will not be triggered until the
157
- * next event loop iteration.
158
- *
159
- * If `callback` is not a function, a `TypeError` will be thrown.
160
- *
161
- * This method has a custom variant for promises that is available using
162
- * `timersPromises.setImmediate()`.
163
- * @since v0.9.1
164
- * @param callback The function to call at the end of this turn of
165
- * the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout)
166
- * @param args Optional arguments to pass when the `callback` is called.
167
- * @returns for use with `clearImmediate()`
168
- */
169
- function setImmediate<TArgs extends any[]>(
170
- callback: (...args: TArgs) => void,
171
- ...args: TArgs
172
- ): NodeJS.Immediate;
173
- // Allow a single void-accepting argument to be optional in arguments lists.
174
- // Allows usage such as `new Promise(resolve => setTimeout(resolve, ms))` (#54258)
175
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
176
- function setImmediate(callback: (_: void) => void): NodeJS.Immediate;
177
- namespace setImmediate {
178
- import __promisify__ = promises.setImmediate;
179
- export { __promisify__ };
180
- }
181
- /**
182
- * Schedules repeated execution of `callback` every `delay` milliseconds.
183
- *
184
- * When `delay` is larger than `2147483647` or less than `1`, the `delay` will be
185
- * set to `1`. Non-integer delays are truncated to an integer.
186
- *
187
- * If `callback` is not a function, a `TypeError` will be thrown.
188
- *
189
- * This method has a custom variant for promises that is available using
190
- * `timersPromises.setInterval()`.
191
- * @since v0.0.1
192
- * @param callback The function to call when the timer elapses.
193
- * @param delay The number of milliseconds to wait before calling the
194
- * `callback`. **Default:** `1`.
195
- * @param args Optional arguments to pass when the `callback` is called.
196
- * @returns for use with `clearInterval()`
197
- */
198
- function setInterval<TArgs extends any[]>(
199
- callback: (...args: TArgs) => void,
200
- delay?: number,
201
- ...args: TArgs
202
- ): NodeJS.Timeout;
203
- // Allow a single void-accepting argument to be optional in arguments lists.
204
- // Allows usage such as `new Promise(resolve => setTimeout(resolve, ms))` (#54258)
205
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
206
- function setInterval(callback: (_: void) => void, delay?: number): NodeJS.Timeout;
207
- /**
208
- * Schedules execution of a one-time `callback` after `delay` milliseconds.
209
- *
210
- * The `callback` will likely not be invoked in precisely `delay` milliseconds.
211
- * Node.js makes no guarantees about the exact timing of when callbacks will fire,
212
- * nor of their ordering. The callback will be called as close as possible to the
213
- * time specified.
214
- *
215
- * When `delay` is larger than `2147483647` or less than `1` or `NaN`, the `delay`
216
- * will be set to `1`. Non-integer delays are truncated to an integer.
217
- *
218
- * If `callback` is not a function, a `TypeError` will be thrown.
219
- *
220
- * This method has a custom variant for promises that is available using
221
- * `timersPromises.setTimeout()`.
222
- * @since v0.0.1
223
- * @param callback The function to call when the timer elapses.
224
- * @param delay The number of milliseconds to wait before calling the
225
- * `callback`. **Default:** `1`.
226
- * @param args Optional arguments to pass when the `callback` is called.
227
- * @returns for use with `clearTimeout()`
228
- */
229
- function setTimeout<TArgs extends any[]>(
230
- callback: (...args: TArgs) => void,
231
- delay?: number,
232
- ...args: TArgs
233
- ): NodeJS.Timeout;
234
- // Allow a single void-accepting argument to be optional in arguments lists.
235
- // Allows usage such as `new Promise(resolve => setTimeout(resolve, ms))` (#54258)
236
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
237
- function setTimeout(callback: (_: void) => void, delay?: number): NodeJS.Timeout;
238
- namespace setTimeout {
239
- import __promisify__ = promises.setTimeout;
240
- export { __promisify__ };
241
- }
242
- /**
243
- * Cancels an `Immediate` object created by `setImmediate()`.
244
- * @since v0.9.1
245
- * @param immediate An `Immediate` object as returned by `setImmediate()`.
246
- */
247
- function clearImmediate(immediate: NodeJS.Immediate | undefined): void;
248
- /**
249
- * Cancels a `Timeout` object created by `setInterval()`.
250
- * @since v0.0.1
251
- * @param timeout A `Timeout` object as returned by `setInterval()`
252
- * or the primitive of the `Timeout` object as a string or a number.
253
- */
254
- function clearInterval(timeout: NodeJS.Timeout | string | number | undefined): void;
255
- /**
256
- * Cancels a `Timeout` object created by `setTimeout()`.
257
- * @since v0.0.1
258
- * @param timeout A `Timeout` object as returned by `setTimeout()`
259
- * or the primitive of the `Timeout` object as a string or a number.
260
- */
261
- function clearTimeout(timeout: NodeJS.Timeout | string | number | undefined): void;
262
- /**
263
- * The `queueMicrotask()` method queues a microtask to invoke `callback`. If
264
- * `callback` throws an exception, the `process` object `'uncaughtException'`
265
- * event will be emitted.
266
- *
267
- * The microtask queue is managed by V8 and may be used in a similar manner to
268
- * the `process.nextTick()` queue, which is managed by Node.js. The
269
- * `process.nextTick()` queue is always processed before the microtask queue
270
- * within each turn of the Node.js event loop.
271
- * @since v11.0.0
272
- * @param callback Function to be queued.
273
- */
274
- function queueMicrotask(callback: () => void): void;
275
- }
276
- import clearImmediate = globalThis.clearImmediate;
277
- import clearInterval = globalThis.clearInterval;
278
- import clearTimeout = globalThis.clearTimeout;
279
- import setImmediate = globalThis.setImmediate;
280
- import setInterval = globalThis.setInterval;
281
- import setTimeout = globalThis.setTimeout;
282
- export { clearImmediate, clearInterval, clearTimeout, promises, setImmediate, setInterval, setTimeout };
283
- }
284
- declare module "node:timers" {
285
- export * from "timers";
286
- }