@upyo/core 0.5.0-dev.164 → 0.5.0-dev.170

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.
@@ -0,0 +1,53 @@
1
+
2
+ //#region src/abort-signal.ts
3
+ /**
4
+ * Combines a primary abort signal with an optional external signal.
5
+ *
6
+ * The returned signal aborts as soon as either input signal aborts. Runtimes
7
+ * with `AbortSignal.any()` use the platform implementation; older runtimes use
8
+ * a listener-based fallback that preserves the original abort reason.
9
+ *
10
+ * @param primarySignal The signal owned by the current operation.
11
+ * @param externalSignal Optional caller-supplied signal to compose.
12
+ * @returns A combined signal and cleanup callback.
13
+ * @since 0.5.0
14
+ */
15
+ function combineSignals(primarySignal, externalSignal) {
16
+ if (externalSignal == null) return {
17
+ signal: primarySignal,
18
+ cleanup: () => {}
19
+ };
20
+ if (typeof AbortSignal.any === "function") return {
21
+ signal: AbortSignal.any([primarySignal, externalSignal]),
22
+ cleanup: () => {}
23
+ };
24
+ const controller = new AbortController();
25
+ const cleanup = () => {
26
+ primarySignal.removeEventListener("abort", abortFromPrimary);
27
+ externalSignal.removeEventListener("abort", abortFromExternal);
28
+ };
29
+ const abortFromPrimary = () => {
30
+ cleanup();
31
+ controller.abort(getAbortReason(primarySignal));
32
+ };
33
+ const abortFromExternal = () => {
34
+ cleanup();
35
+ controller.abort(getAbortReason(externalSignal));
36
+ };
37
+ if (primarySignal.aborted) controller.abort(getAbortReason(primarySignal));
38
+ else if (externalSignal.aborted) controller.abort(getAbortReason(externalSignal));
39
+ else {
40
+ primarySignal.addEventListener("abort", abortFromPrimary, { once: true });
41
+ externalSignal.addEventListener("abort", abortFromExternal, { once: true });
42
+ }
43
+ return {
44
+ signal: controller.signal,
45
+ cleanup
46
+ };
47
+ }
48
+ function getAbortReason(signal) {
49
+ return signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
50
+ }
51
+
52
+ //#endregion
53
+ exports.combineSignals = combineSignals;
@@ -0,0 +1,32 @@
1
+ //#region src/abort-signal.d.ts
2
+ /**
3
+ * Result of combining abort signals.
4
+ *
5
+ * @since 0.5.0
6
+ */
7
+ interface CombinedSignal {
8
+ /**
9
+ * The signal that aborts when any input signal aborts.
10
+ */
11
+ readonly signal: AbortSignal;
12
+ /**
13
+ * Removes fallback abort listeners when signal composition no longer needs
14
+ * them.
15
+ */
16
+ cleanup(): void;
17
+ }
18
+ /**
19
+ * Combines a primary abort signal with an optional external signal.
20
+ *
21
+ * The returned signal aborts as soon as either input signal aborts. Runtimes
22
+ * with `AbortSignal.any()` use the platform implementation; older runtimes use
23
+ * a listener-based fallback that preserves the original abort reason.
24
+ *
25
+ * @param primarySignal The signal owned by the current operation.
26
+ * @param externalSignal Optional caller-supplied signal to compose.
27
+ * @returns A combined signal and cleanup callback.
28
+ * @since 0.5.0
29
+ */
30
+ declare function combineSignals(primarySignal: AbortSignal, externalSignal?: AbortSignal | null): CombinedSignal;
31
+ //#endregion
32
+ export { CombinedSignal, combineSignals };
@@ -0,0 +1,32 @@
1
+ //#region src/abort-signal.d.ts
2
+ /**
3
+ * Result of combining abort signals.
4
+ *
5
+ * @since 0.5.0
6
+ */
7
+ interface CombinedSignal {
8
+ /**
9
+ * The signal that aborts when any input signal aborts.
10
+ */
11
+ readonly signal: AbortSignal;
12
+ /**
13
+ * Removes fallback abort listeners when signal composition no longer needs
14
+ * them.
15
+ */
16
+ cleanup(): void;
17
+ }
18
+ /**
19
+ * Combines a primary abort signal with an optional external signal.
20
+ *
21
+ * The returned signal aborts as soon as either input signal aborts. Runtimes
22
+ * with `AbortSignal.any()` use the platform implementation; older runtimes use
23
+ * a listener-based fallback that preserves the original abort reason.
24
+ *
25
+ * @param primarySignal The signal owned by the current operation.
26
+ * @param externalSignal Optional caller-supplied signal to compose.
27
+ * @returns A combined signal and cleanup callback.
28
+ * @since 0.5.0
29
+ */
30
+ declare function combineSignals(primarySignal: AbortSignal, externalSignal?: AbortSignal | null): CombinedSignal;
31
+ //#endregion
32
+ export { CombinedSignal, combineSignals };
@@ -0,0 +1,52 @@
1
+ //#region src/abort-signal.ts
2
+ /**
3
+ * Combines a primary abort signal with an optional external signal.
4
+ *
5
+ * The returned signal aborts as soon as either input signal aborts. Runtimes
6
+ * with `AbortSignal.any()` use the platform implementation; older runtimes use
7
+ * a listener-based fallback that preserves the original abort reason.
8
+ *
9
+ * @param primarySignal The signal owned by the current operation.
10
+ * @param externalSignal Optional caller-supplied signal to compose.
11
+ * @returns A combined signal and cleanup callback.
12
+ * @since 0.5.0
13
+ */
14
+ function combineSignals(primarySignal, externalSignal) {
15
+ if (externalSignal == null) return {
16
+ signal: primarySignal,
17
+ cleanup: () => {}
18
+ };
19
+ if (typeof AbortSignal.any === "function") return {
20
+ signal: AbortSignal.any([primarySignal, externalSignal]),
21
+ cleanup: () => {}
22
+ };
23
+ const controller = new AbortController();
24
+ const cleanup = () => {
25
+ primarySignal.removeEventListener("abort", abortFromPrimary);
26
+ externalSignal.removeEventListener("abort", abortFromExternal);
27
+ };
28
+ const abortFromPrimary = () => {
29
+ cleanup();
30
+ controller.abort(getAbortReason(primarySignal));
31
+ };
32
+ const abortFromExternal = () => {
33
+ cleanup();
34
+ controller.abort(getAbortReason(externalSignal));
35
+ };
36
+ if (primarySignal.aborted) controller.abort(getAbortReason(primarySignal));
37
+ else if (externalSignal.aborted) controller.abort(getAbortReason(externalSignal));
38
+ else {
39
+ primarySignal.addEventListener("abort", abortFromPrimary, { once: true });
40
+ externalSignal.addEventListener("abort", abortFromExternal, { once: true });
41
+ }
42
+ return {
43
+ signal: controller.signal,
44
+ cleanup
45
+ };
46
+ }
47
+ function getAbortReason(signal) {
48
+ return signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
49
+ }
50
+
51
+ //#endregion
52
+ export { combineSignals };
package/dist/index.cjs CHANGED
@@ -1,11 +1,13 @@
1
1
  const require_address = require('./address.cjs');
2
2
  const require_attachment = require('./attachment.cjs');
3
+ const require_abort_signal = require('./abort-signal.cjs');
3
4
  const require_message = require('./message.cjs');
4
5
  const require_priority = require('./priority.cjs');
5
6
  const require_receipt = require('./receipt.cjs');
6
7
 
7
8
  exports.classifyHttpStatus = require_receipt.classifyHttpStatus;
8
9
  exports.classifyReceiptError = require_receipt.classifyReceiptError;
10
+ exports.combineSignals = require_abort_signal.combineSignals;
9
11
  exports.comparePriority = require_priority.comparePriority;
10
12
  exports.createFailedReceipt = require_receipt.createFailedReceipt;
11
13
  exports.createMessage = require_message.createMessage;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Address, EmailAddress, formatAddress, isEmailAddress, parseAddress } from "./address.cjs";
2
2
  import { Attachment, isAttachment } from "./attachment.cjs";
3
+ import { CombinedSignal, combineSignals } from "./abort-signal.cjs";
3
4
  import { Priority, comparePriority } from "./priority.cjs";
4
5
  import { ImmutableHeaders, Message, MessageConstructor, MessageContent, createMessage } from "./message.cjs";
5
6
  import { CreateFailedReceiptOptions, CreateReceiptErrorOptions, Receipt, ReceiptError, ReceiptErrorCategory, ReceiptErrorClassification, classifyHttpStatus, classifyReceiptError, createFailedReceipt, createReceiptError, parseRetryAfter } from "./receipt.cjs";
6
7
  import { Transport, TransportOptions } from "./transport.cjs";
7
- export { Address, Attachment, CreateFailedReceiptOptions, CreateReceiptErrorOptions, EmailAddress, ImmutableHeaders, Message, MessageConstructor, MessageContent, Priority, Receipt, ReceiptError, ReceiptErrorCategory, ReceiptErrorClassification, Transport, TransportOptions, classifyHttpStatus, classifyReceiptError, comparePriority, createFailedReceipt, createMessage, createReceiptError, formatAddress, isAttachment, isEmailAddress, parseAddress, parseRetryAfter };
8
+ export { Address, Attachment, CombinedSignal, CreateFailedReceiptOptions, CreateReceiptErrorOptions, EmailAddress, ImmutableHeaders, Message, MessageConstructor, MessageContent, Priority, Receipt, ReceiptError, ReceiptErrorCategory, ReceiptErrorClassification, Transport, TransportOptions, classifyHttpStatus, classifyReceiptError, combineSignals, comparePriority, createFailedReceipt, createMessage, createReceiptError, formatAddress, isAttachment, isEmailAddress, parseAddress, parseRetryAfter };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { Address, EmailAddress, formatAddress, isEmailAddress, parseAddress } from "./address.js";
2
2
  import { Attachment, isAttachment } from "./attachment.js";
3
+ import { CombinedSignal, combineSignals } from "./abort-signal.js";
3
4
  import { Priority, comparePriority } from "./priority.js";
4
5
  import { ImmutableHeaders, Message, MessageConstructor, MessageContent, createMessage } from "./message.js";
5
6
  import { CreateFailedReceiptOptions, CreateReceiptErrorOptions, Receipt, ReceiptError, ReceiptErrorCategory, ReceiptErrorClassification, classifyHttpStatus, classifyReceiptError, createFailedReceipt, createReceiptError, parseRetryAfter } from "./receipt.js";
6
7
  import { Transport, TransportOptions } from "./transport.js";
7
- export { Address, Attachment, CreateFailedReceiptOptions, CreateReceiptErrorOptions, EmailAddress, ImmutableHeaders, Message, MessageConstructor, MessageContent, Priority, Receipt, ReceiptError, ReceiptErrorCategory, ReceiptErrorClassification, Transport, TransportOptions, classifyHttpStatus, classifyReceiptError, comparePriority, createFailedReceipt, createMessage, createReceiptError, formatAddress, isAttachment, isEmailAddress, parseAddress, parseRetryAfter };
8
+ export { Address, Attachment, CombinedSignal, CreateFailedReceiptOptions, CreateReceiptErrorOptions, EmailAddress, ImmutableHeaders, Message, MessageConstructor, MessageContent, Priority, Receipt, ReceiptError, ReceiptErrorCategory, ReceiptErrorClassification, Transport, TransportOptions, classifyHttpStatus, classifyReceiptError, combineSignals, comparePriority, createFailedReceipt, createMessage, createReceiptError, formatAddress, isAttachment, isEmailAddress, parseAddress, parseRetryAfter };
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { formatAddress, isEmailAddress, parseAddress } from "./address.js";
2
2
  import { isAttachment } from "./attachment.js";
3
+ import { combineSignals } from "./abort-signal.js";
3
4
  import { createMessage } from "./message.js";
4
5
  import { comparePriority } from "./priority.js";
5
6
  import { classifyHttpStatus, classifyReceiptError, createFailedReceipt, createReceiptError, parseRetryAfter } from "./receipt.js";
6
7
 
7
- export { classifyHttpStatus, classifyReceiptError, comparePriority, createFailedReceipt, createMessage, createReceiptError, formatAddress, isAttachment, isEmailAddress, parseAddress, parseRetryAfter };
8
+ export { classifyHttpStatus, classifyReceiptError, combineSignals, comparePriority, createFailedReceipt, createMessage, createReceiptError, formatAddress, isAttachment, isEmailAddress, parseAddress, parseRetryAfter };
package/dist/receipt.cjs CHANGED
@@ -159,7 +159,7 @@ function parseRetryAfter(value, now = /* @__PURE__ */ new Date()) {
159
159
  const trimmed = value.trim();
160
160
  if (/^\d+$/.test(trimmed)) {
161
161
  const delay$1 = Number(trimmed) * 1e3;
162
- return delay$1 > 0 ? delay$1 : void 0;
162
+ return delay$1;
163
163
  }
164
164
  const timestamp = Date.parse(trimmed);
165
165
  if (Number.isNaN(timestamp)) return void 0;
package/dist/receipt.js CHANGED
@@ -158,7 +158,7 @@ function parseRetryAfter(value, now = /* @__PURE__ */ new Date()) {
158
158
  const trimmed = value.trim();
159
159
  if (/^\d+$/.test(trimmed)) {
160
160
  const delay$1 = Number(trimmed) * 1e3;
161
- return delay$1 > 0 ? delay$1 : void 0;
161
+ return delay$1;
162
162
  }
163
163
  const timestamp = Date.parse(trimmed);
164
164
  if (Number.isNaN(timestamp)) return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upyo/core",
3
- "version": "0.5.0-dev.164",
3
+ "version": "0.5.0-dev.170",
4
4
  "description": "Simple email sending library for Node.js, Deno, Bun, and edge functions",
5
5
  "keywords": [
6
6
  "email",