@upyo/jmap 0.5.0-dev.158 → 0.5.0-dev.168
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/dist/index.cjs +19 -15
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +19 -15
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -208,12 +208,16 @@ var JmapHttpClient = class {
|
|
|
208
208
|
if (error.statusCode >= 400 && error.statusCode < 500) throw error;
|
|
209
209
|
}
|
|
210
210
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
211
|
-
if (attempt === this.config.retries)
|
|
211
|
+
if (attempt === this.config.retries) {
|
|
212
|
+
if (error instanceof JmapApiError) throw error;
|
|
213
|
+
throw new JmapApiError(lastError.message, void 0, void 0, void 0, void 0, attempt + 1);
|
|
214
|
+
}
|
|
212
215
|
const delay = Math.pow(2, attempt) * 1e3;
|
|
213
216
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
|
-
|
|
219
|
+
if (lastError != null) throw lastError;
|
|
220
|
+
throw new Error("Request failed after all retries");
|
|
217
221
|
}
|
|
218
222
|
/**
|
|
219
223
|
* Makes an authenticated fetch request.
|
|
@@ -489,12 +493,14 @@ var JmapTransport = class {
|
|
|
489
493
|
* @param message The message to send.
|
|
490
494
|
* @param options Optional transport options.
|
|
491
495
|
* @returns A receipt indicating success or failure.
|
|
496
|
+
* @throws The abort reason or an `AbortError` when the caller aborts the
|
|
497
|
+
* operation.
|
|
492
498
|
* @since 0.4.0
|
|
493
499
|
*/
|
|
494
500
|
async send(message, options) {
|
|
495
501
|
const signal = options?.signal;
|
|
502
|
+
signal?.throwIfAborted();
|
|
496
503
|
try {
|
|
497
|
-
signal?.throwIfAborted();
|
|
498
504
|
const session = await this.getSession(signal);
|
|
499
505
|
signal?.throwIfAborted();
|
|
500
506
|
const accountId = this.config.accountId ?? findMailAccount(session);
|
|
@@ -537,14 +543,12 @@ var JmapTransport = class {
|
|
|
537
543
|
}, signal);
|
|
538
544
|
return this.parseResponse(response);
|
|
539
545
|
} catch (error) {
|
|
540
|
-
if (
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
});
|
|
547
|
-
}
|
|
546
|
+
if (signal?.aborted) throw getAbortReason(signal, error);
|
|
547
|
+
if (error instanceof Error && error.name === "AbortError") return createJmapFailure(`Request aborted: ${error.message}`, error, {
|
|
548
|
+
category: "timeout",
|
|
549
|
+
code: "abort",
|
|
550
|
+
retryable: true
|
|
551
|
+
});
|
|
548
552
|
if (error instanceof JmapApiError) return createJmapFailure(error.message, error);
|
|
549
553
|
return createJmapFailure(error instanceof Error ? error.message : String(error), error);
|
|
550
554
|
}
|
|
@@ -554,6 +558,8 @@ var JmapTransport = class {
|
|
|
554
558
|
* @param messages The messages to send.
|
|
555
559
|
* @param options Optional transport options.
|
|
556
560
|
* @yields Receipts for each message.
|
|
561
|
+
* @throws The abort reason or an `AbortError` when the caller aborts the
|
|
562
|
+
* operation.
|
|
557
563
|
* @since 0.4.0
|
|
558
564
|
*/
|
|
559
565
|
async *sendMany(messages, options) {
|
|
@@ -633,9 +639,7 @@ var JmapTransport = class {
|
|
|
633
639
|
}, signal);
|
|
634
640
|
for (let i = 0; i < messageArray.length; i++) yield this.parseBatchResponseForIndex(response, i);
|
|
635
641
|
} catch (error) {
|
|
636
|
-
if (
|
|
637
|
-
if (signal?.aborted) throw getAbortReason(signal, error);
|
|
638
|
-
}
|
|
642
|
+
if (signal?.aborted) throw getAbortReason(signal, error);
|
|
639
643
|
const baseMessage = error instanceof Error && error.name === "AbortError" ? `Request aborted: ${error.message}` : error instanceof JmapApiError ? error.message : error instanceof Error ? error.message : String(error);
|
|
640
644
|
let detailedMessage = `Failed during ${processingStage}: ${baseMessage}`;
|
|
641
645
|
if (processingStage === "attachment upload" && attachmentsUploadedCount > 0) detailedMessage += ` (${attachmentsUploadedCount}/${messageArray.length} messages had attachments uploaded before failure)`;
|
|
@@ -879,7 +883,7 @@ function getAttemptCount(error) {
|
|
|
879
883
|
return 1;
|
|
880
884
|
}
|
|
881
885
|
function getAbortReason(signal, fallback) {
|
|
882
|
-
return signal.reason ?? fallback;
|
|
886
|
+
return signal.reason ?? fallback ?? new DOMException("The operation was aborted.", "AbortError");
|
|
883
887
|
}
|
|
884
888
|
|
|
885
889
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -119,6 +119,8 @@ declare class JmapTransport implements Transport<"jmap"> {
|
|
|
119
119
|
* @param message The message to send.
|
|
120
120
|
* @param options Optional transport options.
|
|
121
121
|
* @returns A receipt indicating success or failure.
|
|
122
|
+
* @throws The abort reason or an `AbortError` when the caller aborts the
|
|
123
|
+
* operation.
|
|
122
124
|
* @since 0.4.0
|
|
123
125
|
*/
|
|
124
126
|
send(message: Message, options?: TransportOptions): Promise<Receipt<"jmap">>;
|
|
@@ -127,6 +129,8 @@ declare class JmapTransport implements Transport<"jmap"> {
|
|
|
127
129
|
* @param messages The messages to send.
|
|
128
130
|
* @param options Optional transport options.
|
|
129
131
|
* @yields Receipts for each message.
|
|
132
|
+
* @throws The abort reason or an `AbortError` when the caller aborts the
|
|
133
|
+
* operation.
|
|
130
134
|
* @since 0.4.0
|
|
131
135
|
*/
|
|
132
136
|
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt<"jmap">>;
|
package/dist/index.d.ts
CHANGED
|
@@ -119,6 +119,8 @@ declare class JmapTransport implements Transport<"jmap"> {
|
|
|
119
119
|
* @param message The message to send.
|
|
120
120
|
* @param options Optional transport options.
|
|
121
121
|
* @returns A receipt indicating success or failure.
|
|
122
|
+
* @throws The abort reason or an `AbortError` when the caller aborts the
|
|
123
|
+
* operation.
|
|
122
124
|
* @since 0.4.0
|
|
123
125
|
*/
|
|
124
126
|
send(message: Message, options?: TransportOptions): Promise<Receipt<"jmap">>;
|
|
@@ -127,6 +129,8 @@ declare class JmapTransport implements Transport<"jmap"> {
|
|
|
127
129
|
* @param messages The messages to send.
|
|
128
130
|
* @param options Optional transport options.
|
|
129
131
|
* @yields Receipts for each message.
|
|
132
|
+
* @throws The abort reason or an `AbortError` when the caller aborts the
|
|
133
|
+
* operation.
|
|
130
134
|
* @since 0.4.0
|
|
131
135
|
*/
|
|
132
136
|
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt<"jmap">>;
|
package/dist/index.js
CHANGED
|
@@ -185,12 +185,16 @@ var JmapHttpClient = class {
|
|
|
185
185
|
if (error.statusCode >= 400 && error.statusCode < 500) throw error;
|
|
186
186
|
}
|
|
187
187
|
lastError = error instanceof Error ? error : new Error(String(error));
|
|
188
|
-
if (attempt === this.config.retries)
|
|
188
|
+
if (attempt === this.config.retries) {
|
|
189
|
+
if (error instanceof JmapApiError) throw error;
|
|
190
|
+
throw new JmapApiError(lastError.message, void 0, void 0, void 0, void 0, attempt + 1);
|
|
191
|
+
}
|
|
189
192
|
const delay = Math.pow(2, attempt) * 1e3;
|
|
190
193
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
191
194
|
}
|
|
192
195
|
}
|
|
193
|
-
|
|
196
|
+
if (lastError != null) throw lastError;
|
|
197
|
+
throw new Error("Request failed after all retries");
|
|
194
198
|
}
|
|
195
199
|
/**
|
|
196
200
|
* Makes an authenticated fetch request.
|
|
@@ -466,12 +470,14 @@ var JmapTransport = class {
|
|
|
466
470
|
* @param message The message to send.
|
|
467
471
|
* @param options Optional transport options.
|
|
468
472
|
* @returns A receipt indicating success or failure.
|
|
473
|
+
* @throws The abort reason or an `AbortError` when the caller aborts the
|
|
474
|
+
* operation.
|
|
469
475
|
* @since 0.4.0
|
|
470
476
|
*/
|
|
471
477
|
async send(message, options) {
|
|
472
478
|
const signal = options?.signal;
|
|
479
|
+
signal?.throwIfAborted();
|
|
473
480
|
try {
|
|
474
|
-
signal?.throwIfAborted();
|
|
475
481
|
const session = await this.getSession(signal);
|
|
476
482
|
signal?.throwIfAborted();
|
|
477
483
|
const accountId = this.config.accountId ?? findMailAccount(session);
|
|
@@ -514,14 +520,12 @@ var JmapTransport = class {
|
|
|
514
520
|
}, signal);
|
|
515
521
|
return this.parseResponse(response);
|
|
516
522
|
} catch (error) {
|
|
517
|
-
if (
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
});
|
|
524
|
-
}
|
|
523
|
+
if (signal?.aborted) throw getAbortReason(signal, error);
|
|
524
|
+
if (error instanceof Error && error.name === "AbortError") return createJmapFailure(`Request aborted: ${error.message}`, error, {
|
|
525
|
+
category: "timeout",
|
|
526
|
+
code: "abort",
|
|
527
|
+
retryable: true
|
|
528
|
+
});
|
|
525
529
|
if (error instanceof JmapApiError) return createJmapFailure(error.message, error);
|
|
526
530
|
return createJmapFailure(error instanceof Error ? error.message : String(error), error);
|
|
527
531
|
}
|
|
@@ -531,6 +535,8 @@ var JmapTransport = class {
|
|
|
531
535
|
* @param messages The messages to send.
|
|
532
536
|
* @param options Optional transport options.
|
|
533
537
|
* @yields Receipts for each message.
|
|
538
|
+
* @throws The abort reason or an `AbortError` when the caller aborts the
|
|
539
|
+
* operation.
|
|
534
540
|
* @since 0.4.0
|
|
535
541
|
*/
|
|
536
542
|
async *sendMany(messages, options) {
|
|
@@ -610,9 +616,7 @@ var JmapTransport = class {
|
|
|
610
616
|
}, signal);
|
|
611
617
|
for (let i = 0; i < messageArray.length; i++) yield this.parseBatchResponseForIndex(response, i);
|
|
612
618
|
} catch (error) {
|
|
613
|
-
if (
|
|
614
|
-
if (signal?.aborted) throw getAbortReason(signal, error);
|
|
615
|
-
}
|
|
619
|
+
if (signal?.aborted) throw getAbortReason(signal, error);
|
|
616
620
|
const baseMessage = error instanceof Error && error.name === "AbortError" ? `Request aborted: ${error.message}` : error instanceof JmapApiError ? error.message : error instanceof Error ? error.message : String(error);
|
|
617
621
|
let detailedMessage = `Failed during ${processingStage}: ${baseMessage}`;
|
|
618
622
|
if (processingStage === "attachment upload" && attachmentsUploadedCount > 0) detailedMessage += ` (${attachmentsUploadedCount}/${messageArray.length} messages had attachments uploaded before failure)`;
|
|
@@ -856,7 +860,7 @@ function getAttemptCount(error) {
|
|
|
856
860
|
return 1;
|
|
857
861
|
}
|
|
858
862
|
function getAbortReason(signal, fallback) {
|
|
859
|
-
return signal.reason ?? fallback;
|
|
863
|
+
return signal.reason ?? fallback ?? new DOMException("The operation was aborted.", "AbortError");
|
|
860
864
|
}
|
|
861
865
|
|
|
862
866
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/jmap",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.168",
|
|
4
4
|
"description": "JMAP transport for Upyo email library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@upyo/core": "0.5.0-dev.
|
|
56
|
+
"@upyo/core": "0.5.0-dev.168+1e808a3a"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"jmap-rfc-types": "^0.1.2",
|