codemod 2.0.0-alpha.1 → 2.0.0-alpha.2
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/README.md +57 -2
- package/codemod +17 -30
- package/package.json +78 -10
- package/register.d.mts +11 -0
- package/register.mjs +60 -0
- package/runtime/addon.mjs +59 -0
- package/runtime/ast-grep.mjs +93 -0
- package/runtime/context.mjs +77 -0
- package/runtime/hooks.mjs +9 -0
- package/runtime/host.d.mts +120 -0
- package/runtime/host.mjs +390 -0
- package/runtime/llm.mjs +11 -0
- package/runtime/metrics.mjs +45 -0
- package/runtime/modules.mjs +19 -0
- package/runtime/orchestrator.mjs +657 -0
- package/runtime/runtime.mjs +48 -0
- package/runtime/workflow.mjs +135 -0
- package/testing/index.d.mts +203 -0
- package/testing/index.mjs +638 -0
- package/types/index.d.ts +8 -0
- package/types/langs/angular.d.ts +5 -0
- package/types/langs/c.d.ts +5 -0
- package/types/langs/c_sharp.d.ts +5 -0
- package/types/langs/cpp.d.ts +5 -0
- package/types/langs/css.d.ts +5 -0
- package/types/langs/elixir.d.ts +5 -0
- package/types/langs/go.d.ts +5 -0
- package/types/langs/html.d.ts +5 -0
- package/types/langs/java.d.ts +5 -0
- package/types/langs/javascript.d.ts +5 -0
- package/types/langs/json.d.ts +5 -0
- package/types/langs/kotlin.d.ts +5 -0
- package/types/langs/php.d.ts +5 -0
- package/types/langs/python.d.ts +5 -0
- package/types/langs/ruby.d.ts +5 -0
- package/types/langs/rust.d.ts +5 -0
- package/types/langs/scala.d.ts +5 -0
- package/types/langs/toml.d.ts +5 -0
- package/types/langs/tsx.d.ts +5 -0
- package/types/langs/typescript.d.ts +5 -0
- package/types/langs/xml.d.ts +5 -0
- package/types/langs/yaml.d.ts +5 -0
- package/types/llm.d.ts +6 -0
- package/types/llrt/abort.d.ts +69 -0
- package/types/llrt/assert.d.ts +39 -0
- package/types/llrt/async_hooks.d.ts +210 -0
- package/types/llrt/buffer.d.ts +1186 -0
- package/types/llrt/child_process.d.ts +447 -0
- package/types/llrt/console.d.ts +210 -0
- package/types/llrt/crypto.d.ts +854 -0
- package/types/llrt/dgram.d.ts +381 -0
- package/types/llrt/dns.d.ts +124 -0
- package/types/llrt/dom-events.d.ts +51 -0
- package/types/llrt/events.d.ts +245 -0
- package/types/llrt/exceptions.d.ts +26 -0
- package/types/llrt/fetch.d.ts +332 -0
- package/types/llrt/fs/promises.d.ts +554 -0
- package/types/llrt/fs.d.ts +360 -0
- package/types/llrt/globals.d.ts +23 -0
- package/types/llrt/https.d.ts +27 -0
- package/types/llrt/index.d.ts +33 -0
- package/types/llrt/module.d.ts +285 -0
- package/types/llrt/navigator.d.ts +9 -0
- package/types/llrt/net.d.ts +488 -0
- package/types/llrt/os.d.ts +293 -0
- package/types/llrt/path.d.ts +150 -0
- package/types/llrt/perf_hooks.d.ts +23 -0
- package/types/llrt/process.d.ts +502 -0
- package/types/llrt/stream/web.d.ts +526 -0
- package/types/llrt/stream.d.ts +366 -0
- package/types/llrt/string_decoder.d.ts +63 -0
- package/types/llrt/timers.d.ts +72 -0
- package/types/llrt/timezone.d.ts +101 -0
- package/types/llrt/tty.d.ts +11 -0
- package/types/llrt/url.d.ts +774 -0
- package/types/llrt/util.d.ts +240 -0
- package/types/llrt/zlib.d.ts +177 -0
- package/types/main.d.ts +5 -0
- package/types/metrics.d.ts +5 -0
- package/types/modules/ast-grep.d.ts +634 -0
- package/types/modules/langs.d.ts +87 -0
- package/types/modules/llm.d.ts +23 -0
- package/types/modules/metrics.d.ts +107 -0
- package/types/modules/runtime.d.ts +66 -0
- package/types/modules/workflow.d.ts +750 -0
- package/types/runtime.d.ts +6 -0
- package/types/workflow.d.ts +5 -0
- package/vite.d.mts +24 -0
- package/vite.mjs +26 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `assert` module provides a set of assertion functions for verifying invariants.
|
|
3
|
+
*/
|
|
4
|
+
declare module "assert" {
|
|
5
|
+
/**
|
|
6
|
+
* An alias of {@link ok}.
|
|
7
|
+
* @param value The input that is checked for being truthy.
|
|
8
|
+
*/
|
|
9
|
+
function assert(value: unknown, message?: string | Error): asserts value;
|
|
10
|
+
/**
|
|
11
|
+
* Tests if `value` is truthy.
|
|
12
|
+
*
|
|
13
|
+
* If `value` is not truthy, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is `undefined`, a default
|
|
14
|
+
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
|
15
|
+
* If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
|
|
16
|
+
*
|
|
17
|
+
* ```js
|
|
18
|
+
* import * as assert from 'assert';
|
|
19
|
+
*
|
|
20
|
+
* assert.ok(true);
|
|
21
|
+
* // OK
|
|
22
|
+
* assert.ok(1);
|
|
23
|
+
* // OK
|
|
24
|
+
*
|
|
25
|
+
* assert.ok();
|
|
26
|
+
* // TypeError: Error calling function with 0 argument(s) while 1 where expected
|
|
27
|
+
*
|
|
28
|
+
* assert.ok(false, 'it\'s false');
|
|
29
|
+
* // AssertionError: it's false
|
|
30
|
+
*
|
|
31
|
+
* assert.ok(false);
|
|
32
|
+
* // AssertionError: The expression was evaluated to a falsy value
|
|
33
|
+
*
|
|
34
|
+
* assert.ok(0);
|
|
35
|
+
* // AssertionError: The expression was evaluated to a falsy value
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
function ok(value: unknown, message?: string | Error): asserts value;
|
|
39
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
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-v22.x/api/async_context.html#class-asynclocalstorage) tracks async context
|
|
6
|
+
* * [`process.getActiveResourcesInfo()`](https://nodejs.org/docs/latest-v22.x/api/process.html#processgetactiveresourcesinfo) tracks active resources
|
|
7
|
+
*
|
|
8
|
+
* The `async_hooks` module provides an API to track asynchronous resources.
|
|
9
|
+
* It can be accessed using:
|
|
10
|
+
*
|
|
11
|
+
* ```js
|
|
12
|
+
* import async_hooks from 'async_hooks';
|
|
13
|
+
* ```
|
|
14
|
+
* @experimental
|
|
15
|
+
* @see [source](https://github.com/nodejs/node/blob/v22.x/lib/async_hooks.js)
|
|
16
|
+
*/
|
|
17
|
+
declare module "async_hooks" {
|
|
18
|
+
/**
|
|
19
|
+
* ```js
|
|
20
|
+
* import { executionAsyncId } from 'async_hooks';
|
|
21
|
+
* import fs from '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-v22.x/api/async_hooks.html#promise-execution-tracking).
|
|
48
|
+
* @return The `asyncId` of the current execution context. Useful to track when something calls.
|
|
49
|
+
*/
|
|
50
|
+
function executionAsyncId(): number;
|
|
51
|
+
/**
|
|
52
|
+
* Resource objects returned by `executionAsyncResource()` are most often internal
|
|
53
|
+
* LLRT handle objects with undocumented APIs. Using any functions or properties
|
|
54
|
+
* on the object is likely to crash your application and should be avoided.
|
|
55
|
+
*
|
|
56
|
+
* Using `executionAsyncResource()` in the top-level execution context will
|
|
57
|
+
* return an empty object as there is no handle or request object to use,
|
|
58
|
+
* but having an object representing the top-level can be helpful.
|
|
59
|
+
*
|
|
60
|
+
* ```js
|
|
61
|
+
* import { open } from 'fs';
|
|
62
|
+
* import { executionAsyncId, executionAsyncResource } from 'async_hooks';
|
|
63
|
+
*
|
|
64
|
+
* console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
|
|
65
|
+
* open(new URL(import.meta.url), 'r', (err, fd) => {
|
|
66
|
+
* console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
|
|
67
|
+
* });
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* This can be used to implement continuation local storage without the
|
|
71
|
+
* use of a tracking `Map` to store the metadata:
|
|
72
|
+
*
|
|
73
|
+
* ```js
|
|
74
|
+
* import { createServer } from 'http';
|
|
75
|
+
* import {
|
|
76
|
+
* executionAsyncId,
|
|
77
|
+
* executionAsyncResource,
|
|
78
|
+
* createHook,
|
|
79
|
+
* } from 'async_hooks';
|
|
80
|
+
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
|
81
|
+
*
|
|
82
|
+
* createHook({
|
|
83
|
+
* init(asyncId, type, triggerAsyncId, resource) {
|
|
84
|
+
* const cr = executionAsyncResource();
|
|
85
|
+
* if (cr) {
|
|
86
|
+
* resource[sym] = cr[sym];
|
|
87
|
+
* }
|
|
88
|
+
* },
|
|
89
|
+
* }).enable();
|
|
90
|
+
*
|
|
91
|
+
* const server = createServer((req, res) => {
|
|
92
|
+
* executionAsyncResource()[sym] = { state: req.url };
|
|
93
|
+
* setTimeout(function() {
|
|
94
|
+
* res.end(JSON.stringify(executionAsyncResource()[sym]));
|
|
95
|
+
* }, 100);
|
|
96
|
+
* }).listen(3000);
|
|
97
|
+
* ```
|
|
98
|
+
* @return The resource representing the current execution. Useful to store data within the resource.
|
|
99
|
+
*/
|
|
100
|
+
function executionAsyncResource(): object;
|
|
101
|
+
/**
|
|
102
|
+
* ```js
|
|
103
|
+
* const server = net.createServer((conn) => {
|
|
104
|
+
* // The resource that caused (or triggered) this callback to be called
|
|
105
|
+
* // was that of the new connection. Thus the return value of triggerAsyncId()
|
|
106
|
+
* // is the asyncId of "conn".
|
|
107
|
+
* async_hooks.triggerAsyncId();
|
|
108
|
+
*
|
|
109
|
+
* }).listen(port, () => {
|
|
110
|
+
* // Even though all callbacks passed to .listen() are wrapped in a nextTick()
|
|
111
|
+
* // the callback itself exists because the call to the server's .listen()
|
|
112
|
+
* // was made. So the return value would be the ID of the server.
|
|
113
|
+
* async_hooks.triggerAsyncId();
|
|
114
|
+
* });
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
|
118
|
+
* the section on [promise execution tracking](https://nodejs.org/docs/latest-v22.x/api/async_hooks.html#promise-execution-tracking).
|
|
119
|
+
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
|
120
|
+
*/
|
|
121
|
+
function triggerAsyncId(): number;
|
|
122
|
+
interface HookCallbacks {
|
|
123
|
+
/**
|
|
124
|
+
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
|
125
|
+
* @param asyncId A unique ID for the async resource
|
|
126
|
+
* @param type The type of the async resource
|
|
127
|
+
* @param triggerAsyncId The unique ID of the async resource in whose execution context this async resource was created
|
|
128
|
+
*/
|
|
129
|
+
init?(asyncId: number, type: string, triggerAsyncId: number): void;
|
|
130
|
+
/**
|
|
131
|
+
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
|
132
|
+
* The before callback is called just before said callback is executed.
|
|
133
|
+
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
|
134
|
+
*/
|
|
135
|
+
before?(asyncId: number): void;
|
|
136
|
+
/**
|
|
137
|
+
* Called immediately after the callback specified in `before` is completed.
|
|
138
|
+
*
|
|
139
|
+
* If an uncaught exception occurs during execution of the callback, then `after` will run after the `'uncaughtException'` event is emitted or a `domain`'s handler runs.
|
|
140
|
+
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
|
141
|
+
*/
|
|
142
|
+
after?(asyncId: number): void;
|
|
143
|
+
/**
|
|
144
|
+
* Called when a promise has resolve() called. This may not be in the same execution id
|
|
145
|
+
* as the promise itself.
|
|
146
|
+
* @param asyncId the unique id for the promise that was resolve()d.
|
|
147
|
+
*/
|
|
148
|
+
promiseResolve?(asyncId: number): void;
|
|
149
|
+
/**
|
|
150
|
+
* Called after the resource corresponding to asyncId is destroyed
|
|
151
|
+
* @param asyncId a unique ID for the async resource
|
|
152
|
+
*/
|
|
153
|
+
destroy?(asyncId: number): void;
|
|
154
|
+
}
|
|
155
|
+
interface AsyncHook {
|
|
156
|
+
/**
|
|
157
|
+
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
|
158
|
+
*/
|
|
159
|
+
enable(): this;
|
|
160
|
+
/**
|
|
161
|
+
* 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.
|
|
162
|
+
*/
|
|
163
|
+
disable(): this;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Registers functions to be called for different lifetime events of each async
|
|
167
|
+
* operation.
|
|
168
|
+
*
|
|
169
|
+
* The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
|
|
170
|
+
* respective asynchronous event during a resource's lifetime.
|
|
171
|
+
*
|
|
172
|
+
* All callbacks are optional. For example, if only resource cleanup needs to
|
|
173
|
+
* be tracked, then only the `destroy` callback needs to be passed. The
|
|
174
|
+
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
|
|
175
|
+
*
|
|
176
|
+
* ```js
|
|
177
|
+
* import { createHook } from 'async_hooks';
|
|
178
|
+
*
|
|
179
|
+
* const asyncHook = createHook({
|
|
180
|
+
* init(asyncId, type, triggerAsyncId, resource) { },
|
|
181
|
+
* destroy(asyncId) { },
|
|
182
|
+
* });
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* The callbacks will be inherited via the prototype chain:
|
|
186
|
+
*
|
|
187
|
+
* ```js
|
|
188
|
+
* class MyAsyncCallbacks {
|
|
189
|
+
* init(asyncId, type, triggerAsyncId, resource) { }
|
|
190
|
+
* destroy(asyncId) {}
|
|
191
|
+
* }
|
|
192
|
+
*
|
|
193
|
+
* class MyAddedCallbacks extends MyAsyncCallbacks {
|
|
194
|
+
* before(asyncId) { }
|
|
195
|
+
* after(asyncId) { }
|
|
196
|
+
* }
|
|
197
|
+
*
|
|
198
|
+
* const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* Because promises are asynchronous resources whose lifecycle is tracked
|
|
202
|
+
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
|
|
203
|
+
* @param callbacks The `Hook Callbacks` to register
|
|
204
|
+
* @return Instance used for disabling and enabling hooks
|
|
205
|
+
*/
|
|
206
|
+
function createHook(callbacks: HookCallbacks): AsyncHook;
|
|
207
|
+
}
|
|
208
|
+
declare module "async_hooks" {
|
|
209
|
+
export * from "async_hooks";
|
|
210
|
+
}
|