agentmail 0.0.9

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/.env ADDED
@@ -0,0 +1 @@
1
+ OPENAI_API_KEY=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
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # AgentMail TypeScript Library
2
+
3
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fagentmail-to%2Fagentmail-node)
4
+ [![npm shield](https://img.shields.io/npm/v/agentmail)](https://www.npmjs.com/package/agentmail)
5
+
6
+ The AgentMail TypeScript library provides convenient access to the AgentMail API from TypeScript.
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ npm i -s agentmail
12
+ ```
13
+
14
+ ## Reference
15
+
16
+ A full reference for this library is available [here](./reference.md).
17
+
18
+ ## Usage
19
+
20
+ Instantiate and use the client with the following:
21
+
22
+ ```typescript
23
+ import { AgentMailApiEnvironment, AgentMailApiClient } from "agentmail";
24
+
25
+ const client = new AgentMailApiClient({ environment: AgentMailApiEnvironment.Production, apiKey: "YOUR_API_KEY" });
26
+ await client.inboxes.createInbox({
27
+ domain: "yourdomain.com",
28
+ });
29
+ ```
30
+
31
+ ## Request And Response Types
32
+
33
+ The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
34
+ following namespace:
35
+
36
+ ```typescript
37
+ import { AgentMailApi } from "agentmail";
38
+
39
+ const request: AgentMailApi.ListInboxesRequest = {
40
+ ...
41
+ };
42
+ ```
43
+
44
+ ## Exception Handling
45
+
46
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
47
+ will be thrown.
48
+
49
+ ```typescript
50
+ import { AgentMailApiError } from "agentmail";
51
+
52
+ try {
53
+ await client.inboxes.createInbox(...);
54
+ } catch (err) {
55
+ if (err instanceof AgentMailApiError) {
56
+ console.log(err.statusCode);
57
+ console.log(err.message);
58
+ console.log(err.body);
59
+ }
60
+ }
61
+ ```
62
+
63
+ ## Advanced
64
+
65
+ ### Additional Headers
66
+
67
+ If you would like to send additional headers as part of the request, use the `headers` request option.
68
+
69
+ ```typescript
70
+ const response = await client.inboxes.createInbox(..., {
71
+ headers: {
72
+ 'X-Custom-Header': 'custom value'
73
+ }
74
+ });
75
+ ```
76
+
77
+ ### Retries
78
+
79
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
80
+ as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
81
+ retry limit (default: 2).
82
+
83
+ A request is deemed retriable when any of the following HTTP status codes is returned:
84
+
85
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
86
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
87
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
88
+
89
+ Use the `maxRetries` request option to configure this behavior.
90
+
91
+ ```typescript
92
+ const response = await client.inboxes.createInbox(..., {
93
+ maxRetries: 0 // override maxRetries at the request level
94
+ });
95
+ ```
96
+
97
+ ### Timeouts
98
+
99
+ The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
100
+
101
+ ```typescript
102
+ const response = await client.inboxes.createInbox(..., {
103
+ timeoutInSeconds: 30 // override timeout to 30s
104
+ });
105
+ ```
106
+
107
+ ### Aborting Requests
108
+
109
+ The SDK allows users to abort requests at any point by passing in an abort signal.
110
+
111
+ ```typescript
112
+ const controller = new AbortController();
113
+ const response = await client.inboxes.createInbox(..., {
114
+ abortSignal: controller.signal
115
+ });
116
+ controller.abort(); // aborts the request
117
+ ```
118
+
119
+ ### Runtime Compatibility
120
+
121
+ The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following
122
+ runtimes:
123
+
124
+ - Node.js 18+
125
+ - Vercel
126
+ - Cloudflare Workers
127
+ - Deno v1.25+
128
+ - Bun 1.0+
129
+ - React Native
130
+
131
+ ### Customizing Fetch Client
132
+
133
+ The SDK provides a way for your to customize the underlying HTTP client / Fetch function. If you're running in an
134
+ unsupported environment, this provides a way for you to break glass and ensure the SDK works.
135
+
136
+ ```typescript
137
+ import { AgentMailApiClient } from "agentmail";
138
+
139
+ const client = new AgentMailApiClient({
140
+ ...
141
+ fetcher: // provide your implementation here
142
+ });
143
+ ```
144
+
145
+ ## Contributing
146
+
147
+ While we value open-source contributions to this SDK, this library is generated programmatically.
148
+ Additions made directly to this library would have to be moved over to our generation code,
149
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
150
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
151
+ an issue first to discuss with us!
152
+
153
+ On the other hand, contributions to the README are always very welcome!
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ console.log("Hello World");
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ console.log("Hello World");
@@ -0,0 +1,8 @@
1
+ /** @type {import('jest').Config} */
2
+ export default {
3
+ preset: "ts-jest",
4
+ testEnvironment: "node",
5
+ moduleNameMapper: {
6
+ "(.+)\.js$": "$1",
7
+ },
8
+ };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "agentmail",
3
+ "version": "0.0.9",
4
+ "private": false,
5
+ "repository": "https://github.com/agentmail-to/agentmail-node",
6
+ "main": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "scripts": {
9
+ "format": "prettier . --write --ignore-unknown",
10
+ "build": "tsc",
11
+ "prepack": "cp -rv dist/. .",
12
+ "test": "jest"
13
+ },
14
+ "dependencies": {
15
+ "url-join": "4.0.1",
16
+ "form-data": "^4.0.0",
17
+ "formdata-node": "^6.0.3",
18
+ "node-fetch": "^2.7.0",
19
+ "qs": "^6.13.1",
20
+ "readable-stream": "^4.5.2",
21
+ "js-base64": "3.7.7"
22
+ },
23
+ "devDependencies": {
24
+ "@types/url-join": "4.0.1",
25
+ "@types/qs": "^6.9.17",
26
+ "@types/node-fetch": "^2.6.12",
27
+ "@types/readable-stream": "^4.0.18",
28
+ "webpack": "^5.97.1",
29
+ "ts-loader": "^9.5.1",
30
+ "jest": "^29.7.0",
31
+ "@types/jest": "^29.5.14",
32
+ "ts-jest": "^29.1.1",
33
+ "jest-environment-jsdom": "^29.7.0",
34
+ "@types/node": "^18.19.70",
35
+ "prettier": "^3.4.2",
36
+ "typescript": "~5.7.2"
37
+ },
38
+ "browser": {
39
+ "fs": false,
40
+ "os": false,
41
+ "path": false
42
+ }
43
+ }
package/reference.md ADDED
@@ -0,0 +1,716 @@
1
+ # Reference
2
+
3
+ ## Inboxes
4
+
5
+ <details><summary><code>client.inboxes.<a href="/src/api/resources/inboxes/client/Client.ts">listInboxes</a>({ ...params }) -> AgentMailApi.ListInboxesResponse</code></summary>
6
+ <dl>
7
+ <dd>
8
+
9
+ #### 🔌 Usage
10
+
11
+ <dl>
12
+ <dd>
13
+
14
+ <dl>
15
+ <dd>
16
+
17
+ ```typescript
18
+ await client.inboxes.listInboxes();
19
+ ```
20
+
21
+ </dd>
22
+ </dl>
23
+ </dd>
24
+ </dl>
25
+
26
+ #### ⚙️ Parameters
27
+
28
+ <dl>
29
+ <dd>
30
+
31
+ <dl>
32
+ <dd>
33
+
34
+ **request:** `AgentMailApi.ListInboxesRequest`
35
+
36
+ </dd>
37
+ </dl>
38
+
39
+ <dl>
40
+ <dd>
41
+
42
+ **requestOptions:** `Inboxes.RequestOptions`
43
+
44
+ </dd>
45
+ </dl>
46
+ </dd>
47
+ </dl>
48
+
49
+ </dd>
50
+ </dl>
51
+ </details>
52
+
53
+ <details><summary><code>client.inboxes.<a href="/src/api/resources/inboxes/client/Client.ts">getInbox</a>(inboxId) -> AgentMailApi.Inbox</code></summary>
54
+ <dl>
55
+ <dd>
56
+
57
+ #### 🔌 Usage
58
+
59
+ <dl>
60
+ <dd>
61
+
62
+ <dl>
63
+ <dd>
64
+
65
+ ```typescript
66
+ await client.inboxes.getInbox("inbox_id");
67
+ ```
68
+
69
+ </dd>
70
+ </dl>
71
+ </dd>
72
+ </dl>
73
+
74
+ #### ⚙️ Parameters
75
+
76
+ <dl>
77
+ <dd>
78
+
79
+ <dl>
80
+ <dd>
81
+
82
+ **inboxId:** `AgentMailApi.InboxId`
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+ <dl>
88
+ <dd>
89
+
90
+ **requestOptions:** `Inboxes.RequestOptions`
91
+
92
+ </dd>
93
+ </dl>
94
+ </dd>
95
+ </dl>
96
+
97
+ </dd>
98
+ </dl>
99
+ </details>
100
+
101
+ <details><summary><code>client.inboxes.<a href="/src/api/resources/inboxes/client/Client.ts">createInbox</a>({ ...params }) -> AgentMailApi.Inbox</code></summary>
102
+ <dl>
103
+ <dd>
104
+
105
+ #### 🔌 Usage
106
+
107
+ <dl>
108
+ <dd>
109
+
110
+ <dl>
111
+ <dd>
112
+
113
+ ```typescript
114
+ await client.inboxes.createInbox({
115
+ username: "yourinbox",
116
+ displayName: "Your Inbox",
117
+ });
118
+ ```
119
+
120
+ </dd>
121
+ </dl>
122
+ </dd>
123
+ </dl>
124
+
125
+ #### ⚙️ Parameters
126
+
127
+ <dl>
128
+ <dd>
129
+
130
+ <dl>
131
+ <dd>
132
+
133
+ **request:** `AgentMailApi.CreateInboxRequest`
134
+
135
+ </dd>
136
+ </dl>
137
+
138
+ <dl>
139
+ <dd>
140
+
141
+ **requestOptions:** `Inboxes.RequestOptions`
142
+
143
+ </dd>
144
+ </dl>
145
+ </dd>
146
+ </dl>
147
+
148
+ </dd>
149
+ </dl>
150
+ </details>
151
+
152
+ <details><summary><code>client.inboxes.<a href="/src/api/resources/inboxes/client/Client.ts">deleteInbox</a>(inboxId) -> void</code></summary>
153
+ <dl>
154
+ <dd>
155
+
156
+ #### 📝 Description
157
+
158
+ <dl>
159
+ <dd>
160
+
161
+ <dl>
162
+ <dd>
163
+
164
+ Delete inbox and all of its threads, messages, and attachments.
165
+
166
+ </dd>
167
+ </dl>
168
+ </dd>
169
+ </dl>
170
+
171
+ #### 🔌 Usage
172
+
173
+ <dl>
174
+ <dd>
175
+
176
+ <dl>
177
+ <dd>
178
+
179
+ ```typescript
180
+ await client.inboxes.deleteInbox("yourinbox@agentmail.to");
181
+ ```
182
+
183
+ </dd>
184
+ </dl>
185
+ </dd>
186
+ </dl>
187
+
188
+ #### ⚙️ Parameters
189
+
190
+ <dl>
191
+ <dd>
192
+
193
+ <dl>
194
+ <dd>
195
+
196
+ **inboxId:** `AgentMailApi.InboxId`
197
+
198
+ </dd>
199
+ </dl>
200
+
201
+ <dl>
202
+ <dd>
203
+
204
+ **requestOptions:** `Inboxes.RequestOptions`
205
+
206
+ </dd>
207
+ </dl>
208
+ </dd>
209
+ </dl>
210
+
211
+ </dd>
212
+ </dl>
213
+ </details>
214
+
215
+ ## Messages
216
+
217
+ <details><summary><code>client.messages.<a href="/src/api/resources/messages/client/Client.ts">listMessages</a>(inboxId, { ...params }) -> AgentMailApi.ListMessagesResponse</code></summary>
218
+ <dl>
219
+ <dd>
220
+
221
+ #### 🔌 Usage
222
+
223
+ <dl>
224
+ <dd>
225
+
226
+ <dl>
227
+ <dd>
228
+
229
+ ```typescript
230
+ await client.messages.listMessages("inbox_id");
231
+ ```
232
+
233
+ </dd>
234
+ </dl>
235
+ </dd>
236
+ </dl>
237
+
238
+ #### ⚙️ Parameters
239
+
240
+ <dl>
241
+ <dd>
242
+
243
+ <dl>
244
+ <dd>
245
+
246
+ **inboxId:** `AgentMailApi.InboxId`
247
+
248
+ </dd>
249
+ </dl>
250
+
251
+ <dl>
252
+ <dd>
253
+
254
+ **request:** `AgentMailApi.ListMessagesRequest`
255
+
256
+ </dd>
257
+ </dl>
258
+
259
+ <dl>
260
+ <dd>
261
+
262
+ **requestOptions:** `Messages.RequestOptions`
263
+
264
+ </dd>
265
+ </dl>
266
+ </dd>
267
+ </dl>
268
+
269
+ </dd>
270
+ </dl>
271
+ </details>
272
+
273
+ <details><summary><code>client.messages.<a href="/src/api/resources/messages/client/Client.ts">getMessage</a>(inboxId, messageId) -> AgentMailApi.Message</code></summary>
274
+ <dl>
275
+ <dd>
276
+
277
+ #### 🔌 Usage
278
+
279
+ <dl>
280
+ <dd>
281
+
282
+ <dl>
283
+ <dd>
284
+
285
+ ```typescript
286
+ await client.messages.getMessage("inbox_id", "message_id");
287
+ ```
288
+
289
+ </dd>
290
+ </dl>
291
+ </dd>
292
+ </dl>
293
+
294
+ #### ⚙️ Parameters
295
+
296
+ <dl>
297
+ <dd>
298
+
299
+ <dl>
300
+ <dd>
301
+
302
+ **inboxId:** `AgentMailApi.InboxId`
303
+
304
+ </dd>
305
+ </dl>
306
+
307
+ <dl>
308
+ <dd>
309
+
310
+ **messageId:** `AgentMailApi.MessageId`
311
+
312
+ </dd>
313
+ </dl>
314
+
315
+ <dl>
316
+ <dd>
317
+
318
+ **requestOptions:** `Messages.RequestOptions`
319
+
320
+ </dd>
321
+ </dl>
322
+ </dd>
323
+ </dl>
324
+
325
+ </dd>
326
+ </dl>
327
+ </details>
328
+
329
+ <details><summary><code>client.messages.<a href="/src/api/resources/messages/client/Client.ts">deleteMessage</a>(inboxId, messageId) -> void</code></summary>
330
+ <dl>
331
+ <dd>
332
+
333
+ #### 📝 Description
334
+
335
+ <dl>
336
+ <dd>
337
+
338
+ <dl>
339
+ <dd>
340
+
341
+ Delete message and its attachments.
342
+
343
+ </dd>
344
+ </dl>
345
+ </dd>
346
+ </dl>
347
+
348
+ #### 🔌 Usage
349
+
350
+ <dl>
351
+ <dd>
352
+
353
+ <dl>
354
+ <dd>
355
+
356
+ ```typescript
357
+ await client.messages.deleteMessage("inbox_id", "message_id");
358
+ ```
359
+
360
+ </dd>
361
+ </dl>
362
+ </dd>
363
+ </dl>
364
+
365
+ #### ⚙️ Parameters
366
+
367
+ <dl>
368
+ <dd>
369
+
370
+ <dl>
371
+ <dd>
372
+
373
+ **inboxId:** `AgentMailApi.InboxId`
374
+
375
+ </dd>
376
+ </dl>
377
+
378
+ <dl>
379
+ <dd>
380
+
381
+ **messageId:** `AgentMailApi.MessageId`
382
+
383
+ </dd>
384
+ </dl>
385
+
386
+ <dl>
387
+ <dd>
388
+
389
+ **requestOptions:** `Messages.RequestOptions`
390
+
391
+ </dd>
392
+ </dl>
393
+ </dd>
394
+ </dl>
395
+
396
+ </dd>
397
+ </dl>
398
+ </details>
399
+
400
+ <details><summary><code>client.messages.<a href="/src/api/resources/messages/client/Client.ts">sendMessage</a>(inboxId, { ...params }) -> AgentMailApi.SendMessageResponse</code></summary>
401
+ <dl>
402
+ <dd>
403
+
404
+ #### 🔌 Usage
405
+
406
+ <dl>
407
+ <dd>
408
+
409
+ <dl>
410
+ <dd>
411
+
412
+ ```typescript
413
+ await client.messages.sendMessage("inbox_id", {
414
+ to: "to",
415
+ cc: undefined,
416
+ bcc: undefined,
417
+ subject: undefined,
418
+ text: undefined,
419
+ html: undefined,
420
+ });
421
+ ```
422
+
423
+ </dd>
424
+ </dl>
425
+ </dd>
426
+ </dl>
427
+
428
+ #### ⚙️ Parameters
429
+
430
+ <dl>
431
+ <dd>
432
+
433
+ <dl>
434
+ <dd>
435
+
436
+ **inboxId:** `AgentMailApi.InboxId`
437
+
438
+ </dd>
439
+ </dl>
440
+
441
+ <dl>
442
+ <dd>
443
+
444
+ **request:** `AgentMailApi.SendMessageRequest`
445
+
446
+ </dd>
447
+ </dl>
448
+
449
+ <dl>
450
+ <dd>
451
+
452
+ **requestOptions:** `Messages.RequestOptions`
453
+
454
+ </dd>
455
+ </dl>
456
+ </dd>
457
+ </dl>
458
+
459
+ </dd>
460
+ </dl>
461
+ </details>
462
+
463
+ <details><summary><code>client.messages.<a href="/src/api/resources/messages/client/Client.ts">replyToMessage</a>(inboxId, messageId, { ...params }) -> AgentMailApi.SendMessageResponse</code></summary>
464
+ <dl>
465
+ <dd>
466
+
467
+ #### 🔌 Usage
468
+
469
+ <dl>
470
+ <dd>
471
+
472
+ <dl>
473
+ <dd>
474
+
475
+ ```typescript
476
+ await client.messages.replyToMessage("inbox_id", "message_id", {
477
+ to: undefined,
478
+ cc: undefined,
479
+ bcc: undefined,
480
+ text: undefined,
481
+ html: undefined,
482
+ });
483
+ ```
484
+
485
+ </dd>
486
+ </dl>
487
+ </dd>
488
+ </dl>
489
+
490
+ #### ⚙️ Parameters
491
+
492
+ <dl>
493
+ <dd>
494
+
495
+ <dl>
496
+ <dd>
497
+
498
+ **inboxId:** `AgentMailApi.InboxId`
499
+
500
+ </dd>
501
+ </dl>
502
+
503
+ <dl>
504
+ <dd>
505
+
506
+ **messageId:** `AgentMailApi.MessageId`
507
+
508
+ </dd>
509
+ </dl>
510
+
511
+ <dl>
512
+ <dd>
513
+
514
+ **request:** `AgentMailApi.ReplyToMessageRequest`
515
+
516
+ </dd>
517
+ </dl>
518
+
519
+ <dl>
520
+ <dd>
521
+
522
+ **requestOptions:** `Messages.RequestOptions`
523
+
524
+ </dd>
525
+ </dl>
526
+ </dd>
527
+ </dl>
528
+
529
+ </dd>
530
+ </dl>
531
+ </details>
532
+
533
+ ## Threads
534
+
535
+ <details><summary><code>client.threads.<a href="/src/api/resources/threads/client/Client.ts">listThreads</a>(inboxId, { ...params }) -> AgentMailApi.ListThreadsResponse</code></summary>
536
+ <dl>
537
+ <dd>
538
+
539
+ #### 🔌 Usage
540
+
541
+ <dl>
542
+ <dd>
543
+
544
+ <dl>
545
+ <dd>
546
+
547
+ ```typescript
548
+ await client.threads.listThreads("inbox_id");
549
+ ```
550
+
551
+ </dd>
552
+ </dl>
553
+ </dd>
554
+ </dl>
555
+
556
+ #### ⚙️ Parameters
557
+
558
+ <dl>
559
+ <dd>
560
+
561
+ <dl>
562
+ <dd>
563
+
564
+ **inboxId:** `AgentMailApi.InboxId`
565
+
566
+ </dd>
567
+ </dl>
568
+
569
+ <dl>
570
+ <dd>
571
+
572
+ **request:** `AgentMailApi.ListThreadsRequest`
573
+
574
+ </dd>
575
+ </dl>
576
+
577
+ <dl>
578
+ <dd>
579
+
580
+ **requestOptions:** `Threads.RequestOptions`
581
+
582
+ </dd>
583
+ </dl>
584
+ </dd>
585
+ </dl>
586
+
587
+ </dd>
588
+ </dl>
589
+ </details>
590
+
591
+ <details><summary><code>client.threads.<a href="/src/api/resources/threads/client/Client.ts">getThread</a>(inboxId, threadId) -> AgentMailApi.Thread</code></summary>
592
+ <dl>
593
+ <dd>
594
+
595
+ #### 🔌 Usage
596
+
597
+ <dl>
598
+ <dd>
599
+
600
+ <dl>
601
+ <dd>
602
+
603
+ ```typescript
604
+ await client.threads.getThread("inbox_id", "thread_id");
605
+ ```
606
+
607
+ </dd>
608
+ </dl>
609
+ </dd>
610
+ </dl>
611
+
612
+ #### ⚙️ Parameters
613
+
614
+ <dl>
615
+ <dd>
616
+
617
+ <dl>
618
+ <dd>
619
+
620
+ **inboxId:** `AgentMailApi.InboxId`
621
+
622
+ </dd>
623
+ </dl>
624
+
625
+ <dl>
626
+ <dd>
627
+
628
+ **threadId:** `AgentMailApi.ThreadId`
629
+
630
+ </dd>
631
+ </dl>
632
+
633
+ <dl>
634
+ <dd>
635
+
636
+ **requestOptions:** `Threads.RequestOptions`
637
+
638
+ </dd>
639
+ </dl>
640
+ </dd>
641
+ </dl>
642
+
643
+ </dd>
644
+ </dl>
645
+ </details>
646
+
647
+ <details><summary><code>client.threads.<a href="/src/api/resources/threads/client/Client.ts">deleteThread</a>(inboxId, threadId) -> void</code></summary>
648
+ <dl>
649
+ <dd>
650
+
651
+ #### 📝 Description
652
+
653
+ <dl>
654
+ <dd>
655
+
656
+ <dl>
657
+ <dd>
658
+
659
+ Delete thread and all of its messages and attachments.
660
+
661
+ </dd>
662
+ </dl>
663
+ </dd>
664
+ </dl>
665
+
666
+ #### 🔌 Usage
667
+
668
+ <dl>
669
+ <dd>
670
+
671
+ <dl>
672
+ <dd>
673
+
674
+ ```typescript
675
+ await client.threads.deleteThread("inbox_id", "thread_id");
676
+ ```
677
+
678
+ </dd>
679
+ </dl>
680
+ </dd>
681
+ </dl>
682
+
683
+ #### ⚙️ Parameters
684
+
685
+ <dl>
686
+ <dd>
687
+
688
+ <dl>
689
+ <dd>
690
+
691
+ **inboxId:** `AgentMailApi.InboxId`
692
+
693
+ </dd>
694
+ </dl>
695
+
696
+ <dl>
697
+ <dd>
698
+
699
+ **threadId:** `AgentMailApi.ThreadId`
700
+
701
+ </dd>
702
+ </dl>
703
+
704
+ <dl>
705
+ <dd>
706
+
707
+ **requestOptions:** `Threads.RequestOptions`
708
+
709
+ </dd>
710
+ </dl>
711
+ </dd>
712
+ </dl>
713
+
714
+ </dd>
715
+ </dl>
716
+ </details>
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs").promises;
4
+ const path = require("path");
5
+
6
+ const extensionMap = {
7
+ ".js": ".mjs",
8
+ ".d.ts": ".d.mts",
9
+ };
10
+ const oldExtensions = Object.keys(extensionMap);
11
+
12
+ async function findFiles(rootPath) {
13
+ const files = [];
14
+
15
+ async function scan(directory) {
16
+ const entries = await fs.readdir(directory, { withFileTypes: true });
17
+
18
+ for (const entry of entries) {
19
+ const fullPath = path.join(directory, entry.name);
20
+
21
+ if (entry.isDirectory()) {
22
+ if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
23
+ await scan(fullPath);
24
+ }
25
+ } else if (entry.isFile()) {
26
+ if (oldExtensions.some((ext) => entry.name.endsWith(ext))) {
27
+ files.push(fullPath);
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ await scan(rootPath);
34
+ return files;
35
+ }
36
+
37
+ async function updateFiles(files) {
38
+ const updatedFiles = [];
39
+ for (const file of files) {
40
+ const updated = await updateFileContents(file);
41
+ updatedFiles.push(updated);
42
+ }
43
+
44
+ console.log(`Updated imports in ${updatedFiles.length} files.`);
45
+ }
46
+
47
+ async function updateFileContents(file) {
48
+ const content = await fs.readFile(file, "utf8");
49
+
50
+ let newContent = content;
51
+ // Update each extension type defined in the map
52
+ for (const [oldExt, newExt] of Object.entries(extensionMap)) {
53
+ const regex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g");
54
+ newContent = newContent.replace(regex, `$1$2$3${newExt}$5`);
55
+ }
56
+
57
+ if (content !== newContent) {
58
+ await fs.writeFile(file, newContent, "utf8");
59
+ return true;
60
+ }
61
+ return false;
62
+ }
63
+
64
+ async function renameFiles(files) {
65
+ let counter = 0;
66
+ for (const file of files) {
67
+ const ext = oldExtensions.find((ext) => file.endsWith(ext));
68
+ const newExt = extensionMap[ext];
69
+
70
+ if (newExt) {
71
+ const newPath = file.slice(0, -ext.length) + newExt;
72
+ await fs.rename(file, newPath);
73
+ counter++;
74
+ }
75
+ }
76
+
77
+ console.log(`Renamed ${counter} files.`);
78
+ }
79
+
80
+ async function main() {
81
+ try {
82
+ const targetDir = process.argv[2];
83
+ if (!targetDir) {
84
+ console.error("Please provide a target directory");
85
+ process.exit(1);
86
+ }
87
+
88
+ const targetPath = path.resolve(targetDir);
89
+ const targetStats = await fs.stat(targetPath);
90
+
91
+ if (!targetStats.isDirectory()) {
92
+ console.error("The provided path is not a directory");
93
+ process.exit(1);
94
+ }
95
+
96
+ console.log(`Scanning directory: ${targetDir}`);
97
+
98
+ const files = await findFiles(targetDir);
99
+
100
+ if (files.length === 0) {
101
+ console.log("No matching files found.");
102
+ process.exit(0);
103
+ }
104
+
105
+ console.log(`Found ${files.length} files.`);
106
+ await updateFiles(files);
107
+ await renameFiles(files);
108
+ console.log("\nDone!");
109
+ } catch (error) {
110
+ console.error("An error occurred:", error.message);
111
+ process.exit(1);
112
+ }
113
+ }
114
+
115
+ main();