@c9up/rover 0.1.15 → 0.1.17
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/Mail.d.ts +8 -4
- package/dist/Mail.d.ts.map +1 -1
- package/dist/Mail.js.map +1 -1
- package/dist/MessageBuilder.js +1 -1
- package/dist/MessageBuilder.js.map +1 -1
- package/dist/RoverProvider.d.ts +8 -0
- package/dist/RoverProvider.d.ts.map +1 -1
- package/dist/RoverProvider.js +32 -10
- package/dist/RoverProvider.js.map +1 -1
- package/dist/augmentations.d.ts +29 -0
- package/dist/augmentations.d.ts.map +1 -0
- package/dist/augmentations.js +18 -0
- package/dist/augmentations.js.map +1 -0
- package/dist/emitSafely.d.ts +18 -0
- package/dist/emitSafely.d.ts.map +1 -0
- package/dist/emitSafely.js +22 -0
- package/dist/emitSafely.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/queue/MemoryMailMessenger.d.ts.map +1 -1
- package/dist/queue/MemoryMailMessenger.js +14 -15
- package/dist/queue/MemoryMailMessenger.js.map +1 -1
- package/dist/retry.d.ts +10 -1
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +9 -0
- package/dist/retry.js.map +1 -1
- package/dist/services/main.d.ts +9 -0
- package/dist/services/main.d.ts.map +1 -1
- package/dist/services/main.js +11 -0
- package/dist/services/main.js.map +1 -1
- package/dist/templating/loadNapi.d.ts.map +1 -1
- package/dist/templating/loadNapi.js +7 -16
- package/dist/templating/loadNapi.js.map +1 -1
- package/dist/testing/FakeMail.d.ts +4 -2
- package/dist/testing/FakeMail.d.ts.map +1 -1
- package/dist/testing/FakeMail.js +4 -19
- package/dist/testing/FakeMail.js.map +1 -1
- package/dist/transports/BrevoTransport.js +6 -3
- package/dist/transports/BrevoTransport.js.map +1 -1
- package/dist/transports/SparkPostTransport.js +6 -3
- package/dist/transports/SparkPostTransport.js.map +1 -1
- package/dist/vendor/nativeBinary.d.ts +43 -0
- package/dist/vendor/nativeBinary.d.ts.map +1 -0
- package/dist/vendor/nativeBinary.js +99 -0
- package/dist/vendor/nativeBinary.js.map +1 -0
- package/dist/webhooks/context.d.ts +9 -1
- package/dist/webhooks/context.d.ts.map +1 -1
- package/dist/webhooks/mailgun.d.ts.map +1 -1
- package/dist/webhooks/mailgun.js +2 -1
- package/dist/webhooks/mailgun.js.map +1 -1
- package/dist/webhooks/resend.d.ts.map +1 -1
- package/dist/webhooks/resend.js +2 -1
- package/dist/webhooks/resend.js.map +1 -1
- package/dist/webhooks/sendgrid.d.ts.map +1 -1
- package/dist/webhooks/sendgrid.js +2 -1
- package/dist/webhooks/sendgrid.js.map +1 -1
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +7 -3
- package/scripts/build-napi-types.mjs +4 -3
- package/scripts/generate-napi-types.mjs +9 -6
- package/src/Mail.ts +10 -6
- package/src/MessageBuilder.ts +1 -1
- package/src/RoverProvider.ts +38 -9
- package/src/augmentations.ts +33 -0
- package/src/emitSafely.ts +31 -0
- package/src/index.ts +2 -0
- package/src/queue/MemoryMailMessenger.ts +15 -14
- package/src/retry.ts +11 -2
- package/src/services/main.ts +12 -0
- package/src/templating/loadNapi.ts +11 -17
- package/src/testing/FakeMail.ts +12 -3
- package/src/transports/BrevoTransport.ts +6 -3
- package/src/transports/SparkPostTransport.ts +6 -3
- package/src/vendor/nativeBinary.ts +110 -0
- package/src/webhooks/context.ts +9 -1
- package/src/webhooks/mailgun.ts +2 -1
- package/src/webhooks/resend.ts +2 -1
- package/src/webhooks/sendgrid.ts +2 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Generated from scripts/vendor/nativeBinary.ts — do not edit.
|
|
2
|
+
//
|
|
3
|
+
// This package is published and built from its own repository, so the file
|
|
4
|
+
// has to exist here rather than be imported. `pnpm vendor:sync` rewrites it,
|
|
5
|
+
// and `pnpm vendor:check` fails if this copy has drifted from the original.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Finding the NAPI binary a package ships beside itself.
|
|
9
|
+
*
|
|
10
|
+
* Every package with a Rust engine repeats the same table: napi-rs names its
|
|
11
|
+
* artefacts `index.<platform>-<arch>-<abi>.node`, and the mapping from Node's
|
|
12
|
+
* `platform`/`arch` to that suffix is the part that must never differ between
|
|
13
|
+
* packages. Adding a target means adding it everywhere, and a package that
|
|
14
|
+
* missed the edit fails only on that platform — which is exactly the failure
|
|
15
|
+
* nobody reproduces.
|
|
16
|
+
*
|
|
17
|
+
* What is NOT here is the policy. Some packages degrade when the binary is
|
|
18
|
+
* absent and answer `undefined`; others refuse loudly with build instructions.
|
|
19
|
+
* Both are right for their package, so the loader reports what happened and
|
|
20
|
+
* the caller decides.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { createRequire } from "node:module";
|
|
24
|
+
import { dirname, join } from "node:path";
|
|
25
|
+
import { arch, platform } from "node:process";
|
|
26
|
+
import { fileURLToPath } from "node:url";
|
|
27
|
+
|
|
28
|
+
/** Node's `platform-arch` → the suffix napi-rs builds under. */
|
|
29
|
+
const TARGETS: Record<string, string> = {
|
|
30
|
+
"linux-x64": "linux-x64-gnu",
|
|
31
|
+
"linux-arm64": "linux-arm64-gnu",
|
|
32
|
+
"darwin-x64": "darwin-x64",
|
|
33
|
+
"darwin-arm64": "darwin-arm64",
|
|
34
|
+
"win32-x64": "win32-x64-msvc",
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Every `platform-arch` a binary is built for.
|
|
39
|
+
*
|
|
40
|
+
* For the message a package raises when it refuses: "no binary for
|
|
41
|
+
* linux-riscv64" is only actionable next to the list of what there IS.
|
|
42
|
+
*/
|
|
43
|
+
export function supportedTargets(): readonly string[] {
|
|
44
|
+
return Object.keys(TARGETS);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The suffix a given `platform-arch` builds under, or `undefined`. */
|
|
48
|
+
export function nativeTargetSuffix(target: string): string | undefined {
|
|
49
|
+
return TARGETS[target];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The suffix for THIS platform, or `undefined` where no binary is built. */
|
|
53
|
+
export function nativeBinarySuffix(): string | undefined {
|
|
54
|
+
return nativeTargetSuffix(`${platform}-${arch}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Why the binary is not there, phrased for whoever has to fix it.
|
|
59
|
+
*
|
|
60
|
+
* "not found" and "not built for your platform" call for different actions,
|
|
61
|
+
* and a single "unavailable" leaves the reader to guess which one they are
|
|
62
|
+
* looking at.
|
|
63
|
+
*/
|
|
64
|
+
export function unavailableReason(cause?: unknown): string {
|
|
65
|
+
if (cause !== undefined) {
|
|
66
|
+
return `failed to load (${cause instanceof Error ? cause.message : String(cause)})`;
|
|
67
|
+
}
|
|
68
|
+
const target = `${platform}-${arch}`;
|
|
69
|
+
return nativeTargetSuffix(target) !== undefined
|
|
70
|
+
? "binary not found"
|
|
71
|
+
: `no prebuilt binary for ${target}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* `musl` builds under a different suffix, and the failure is otherwise
|
|
76
|
+
* baffling: the file is there, and `require` still refuses it. Worth saying so
|
|
77
|
+
* in a message rather than leaving a reader to discover glibc.
|
|
78
|
+
*/
|
|
79
|
+
export function muslHint(): string {
|
|
80
|
+
return platform === "linux"
|
|
81
|
+
? " On Alpine/musl, the gnu binary will not load — build the musl target."
|
|
82
|
+
: "";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** What a load attempt did, so the caller can apply its own policy. */
|
|
86
|
+
export type NativeBinaryResult<T> =
|
|
87
|
+
| { loaded: true; binary: T }
|
|
88
|
+
| { loaded: false; suffix: string | undefined; cause?: unknown };
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Load `<package root>/index.<suffix>.node`.
|
|
92
|
+
*
|
|
93
|
+
* The path is fixed rather than passed: this file is generated into
|
|
94
|
+
* `<package>/src/vendor/`, so the package root is always two levels up, from
|
|
95
|
+
* `src` and from `dist` alike.
|
|
96
|
+
*/
|
|
97
|
+
export function loadNativeBinary<T>(): NativeBinaryResult<T> {
|
|
98
|
+
const suffix = nativeBinarySuffix();
|
|
99
|
+
if (suffix === undefined) return { loaded: false, suffix };
|
|
100
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
101
|
+
try {
|
|
102
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
103
|
+
return {
|
|
104
|
+
loaded: true,
|
|
105
|
+
binary: nodeRequire(join(here, `../../index.${suffix}.node`)) as T,
|
|
106
|
+
};
|
|
107
|
+
} catch (cause) {
|
|
108
|
+
return { loaded: false, suffix, cause };
|
|
109
|
+
}
|
|
110
|
+
}
|
package/src/webhooks/context.ts
CHANGED
|
@@ -37,5 +37,13 @@ export type WebhookMiddleware = (
|
|
|
37
37
|
) => Promise<void>;
|
|
38
38
|
|
|
39
39
|
export interface WebhookEmitter {
|
|
40
|
-
|
|
40
|
+
/**
|
|
41
|
+
* `unknown`, not `void`. `@adonisjs/events` declares
|
|
42
|
+
* `emit(): Promise<void>` and rethrows when a listener fails and no error
|
|
43
|
+
* handler is registered — and a `void` return ACCEPTS a promise-returning
|
|
44
|
+
* function, so the call site reads as if there were nothing to handle.
|
|
45
|
+
* Duck-typed, so it stays wider than Adonis's own class: a Node
|
|
46
|
+
* EventEmitter returns boolean.
|
|
47
|
+
*/
|
|
48
|
+
emit(event: string, data: unknown): unknown;
|
|
41
49
|
}
|
package/src/webhooks/mailgun.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
3
|
+
import { emitSafely } from "../emitSafely.js";
|
|
3
4
|
import type {
|
|
4
5
|
WebhookEmitter,
|
|
5
6
|
WebhookHttpContext,
|
|
@@ -94,7 +95,7 @@ export function createMailgunWebhookHandler(
|
|
|
94
95
|
const eventName = EVENT_MAP[data.event];
|
|
95
96
|
if (eventName) {
|
|
96
97
|
try {
|
|
97
|
-
emitter
|
|
98
|
+
emitSafely(emitter, eventName, {
|
|
98
99
|
messageId: data.message?.headers?.["message-id"] ?? "",
|
|
99
100
|
to: data.recipient ?? "",
|
|
100
101
|
reason: data.reason,
|
package/src/webhooks/resend.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
3
|
+
import { emitSafely } from "../emitSafely.js";
|
|
3
4
|
import type {
|
|
4
5
|
WebhookEmitter,
|
|
5
6
|
WebhookHttpContext,
|
|
@@ -176,7 +177,7 @@ function emitMappedEvent(
|
|
|
176
177
|
? (payload.data.to[0] ?? "")
|
|
177
178
|
: (payload.data?.to ?? "");
|
|
178
179
|
try {
|
|
179
|
-
emitter
|
|
180
|
+
emitSafely(emitter, mapped, {
|
|
180
181
|
messageId: payload.data?.email_id ?? "",
|
|
181
182
|
to,
|
|
182
183
|
reason: payload.data?.reason,
|
package/src/webhooks/sendgrid.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import { createPublicKey, verify } from "node:crypto";
|
|
3
|
+
import { emitSafely } from "../emitSafely.js";
|
|
3
4
|
import type {
|
|
4
5
|
WebhookEmitter,
|
|
5
6
|
WebhookHttpContext,
|
|
@@ -101,7 +102,7 @@ export function createSendGridWebhookHandler(
|
|
|
101
102
|
const mapped = EVENT_MAP[ev.event];
|
|
102
103
|
if (!mapped) continue;
|
|
103
104
|
try {
|
|
104
|
-
emitter
|
|
105
|
+
emitSafely(emitter, mapped, {
|
|
105
106
|
messageId: ev.sg_message_id ?? "",
|
|
106
107
|
to: ev.email ?? "",
|
|
107
108
|
reason: ev.reason,
|