@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.
Files changed (84) hide show
  1. package/dist/Mail.d.ts +8 -4
  2. package/dist/Mail.d.ts.map +1 -1
  3. package/dist/Mail.js.map +1 -1
  4. package/dist/MessageBuilder.js +1 -1
  5. package/dist/MessageBuilder.js.map +1 -1
  6. package/dist/RoverProvider.d.ts +8 -0
  7. package/dist/RoverProvider.d.ts.map +1 -1
  8. package/dist/RoverProvider.js +32 -10
  9. package/dist/RoverProvider.js.map +1 -1
  10. package/dist/augmentations.d.ts +29 -0
  11. package/dist/augmentations.d.ts.map +1 -0
  12. package/dist/augmentations.js +18 -0
  13. package/dist/augmentations.js.map +1 -0
  14. package/dist/emitSafely.d.ts +18 -0
  15. package/dist/emitSafely.d.ts.map +1 -0
  16. package/dist/emitSafely.js +22 -0
  17. package/dist/emitSafely.js.map +1 -0
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1 -0
  21. package/dist/index.js.map +1 -1
  22. package/dist/queue/MemoryMailMessenger.d.ts.map +1 -1
  23. package/dist/queue/MemoryMailMessenger.js +14 -15
  24. package/dist/queue/MemoryMailMessenger.js.map +1 -1
  25. package/dist/retry.d.ts +10 -1
  26. package/dist/retry.d.ts.map +1 -1
  27. package/dist/retry.js +9 -0
  28. package/dist/retry.js.map +1 -1
  29. package/dist/services/main.d.ts +9 -0
  30. package/dist/services/main.d.ts.map +1 -1
  31. package/dist/services/main.js +11 -0
  32. package/dist/services/main.js.map +1 -1
  33. package/dist/templating/loadNapi.d.ts.map +1 -1
  34. package/dist/templating/loadNapi.js +7 -16
  35. package/dist/templating/loadNapi.js.map +1 -1
  36. package/dist/testing/FakeMail.d.ts +4 -2
  37. package/dist/testing/FakeMail.d.ts.map +1 -1
  38. package/dist/testing/FakeMail.js +4 -19
  39. package/dist/testing/FakeMail.js.map +1 -1
  40. package/dist/transports/BrevoTransport.js +6 -3
  41. package/dist/transports/BrevoTransport.js.map +1 -1
  42. package/dist/transports/SparkPostTransport.js +6 -3
  43. package/dist/transports/SparkPostTransport.js.map +1 -1
  44. package/dist/vendor/nativeBinary.d.ts +43 -0
  45. package/dist/vendor/nativeBinary.d.ts.map +1 -0
  46. package/dist/vendor/nativeBinary.js +99 -0
  47. package/dist/vendor/nativeBinary.js.map +1 -0
  48. package/dist/webhooks/context.d.ts +9 -1
  49. package/dist/webhooks/context.d.ts.map +1 -1
  50. package/dist/webhooks/mailgun.d.ts.map +1 -1
  51. package/dist/webhooks/mailgun.js +2 -1
  52. package/dist/webhooks/mailgun.js.map +1 -1
  53. package/dist/webhooks/resend.d.ts.map +1 -1
  54. package/dist/webhooks/resend.js +2 -1
  55. package/dist/webhooks/resend.js.map +1 -1
  56. package/dist/webhooks/sendgrid.d.ts.map +1 -1
  57. package/dist/webhooks/sendgrid.js +2 -1
  58. package/dist/webhooks/sendgrid.js.map +1 -1
  59. package/index.darwin-arm64.node +0 -0
  60. package/index.darwin-x64.node +0 -0
  61. package/index.linux-arm64-gnu.node +0 -0
  62. package/index.linux-x64-gnu.node +0 -0
  63. package/index.win32-x64-msvc.node +0 -0
  64. package/package.json +7 -3
  65. package/scripts/build-napi-types.mjs +4 -3
  66. package/scripts/generate-napi-types.mjs +9 -6
  67. package/src/Mail.ts +10 -6
  68. package/src/MessageBuilder.ts +1 -1
  69. package/src/RoverProvider.ts +38 -9
  70. package/src/augmentations.ts +33 -0
  71. package/src/emitSafely.ts +31 -0
  72. package/src/index.ts +2 -0
  73. package/src/queue/MemoryMailMessenger.ts +15 -14
  74. package/src/retry.ts +11 -2
  75. package/src/services/main.ts +12 -0
  76. package/src/templating/loadNapi.ts +11 -17
  77. package/src/testing/FakeMail.ts +12 -3
  78. package/src/transports/BrevoTransport.ts +6 -3
  79. package/src/transports/SparkPostTransport.ts +6 -3
  80. package/src/vendor/nativeBinary.ts +110 -0
  81. package/src/webhooks/context.ts +9 -1
  82. package/src/webhooks/mailgun.ts +2 -1
  83. package/src/webhooks/resend.ts +2 -1
  84. 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
+ }
@@ -37,5 +37,13 @@ export type WebhookMiddleware = (
37
37
  ) => Promise<void>;
38
38
 
39
39
  export interface WebhookEmitter {
40
- emit(event: string, data: unknown): void;
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
  }
@@ -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.emit(eventName, {
98
+ emitSafely(emitter, eventName, {
98
99
  messageId: data.message?.headers?.["message-id"] ?? "",
99
100
  to: data.recipient ?? "",
100
101
  reason: data.reason,
@@ -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.emit(mapped, {
180
+ emitSafely(emitter, mapped, {
180
181
  messageId: payload.data?.email_id ?? "",
181
182
  to,
182
183
  reason: payload.data?.reason,
@@ -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.emit(mapped, {
105
+ emitSafely(emitter, mapped, {
105
106
  messageId: ev.sg_message_id ?? "",
106
107
  to: ev.email ?? "",
107
108
  reason: ev.reason,