@raisindb/functions-types 0.3.0 → 0.4.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/raisin.d.ts +38 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raisindb/functions-types",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "TypeScript type definitions for the RaisinDB server-side function runtime (QuickJS)",
5
5
  "license": "MIT",
6
6
  "types": "raisin.d.ts",
package/raisin.d.ts CHANGED
@@ -298,6 +298,44 @@ declare namespace raisin {
298
298
  function diffDays(ts1: number, ts2: number): Promise<number>;
299
299
  }
300
300
 
301
+ /**
302
+ * One outbound transactional email. The sender is deliberately absent:
303
+ * `from`, the display name and `replyTo` come from the tenant's
304
+ * `/config/email` node, so a function cannot send as an unverified address.
305
+ */
306
+ interface EmailMessage {
307
+ /** One recipient address, or several. */
308
+ to: string | string[];
309
+ subject: string;
310
+ /** Plain-text body. Always required, even alongside `html`. */
311
+ text: string;
312
+ html?: string;
313
+ }
314
+
315
+ /** Proof that the provider accepted a message. Acceptance is not delivery. */
316
+ interface EmailReceipt {
317
+ /** The provider's message id — what a later bounce/webhook correlates to. */
318
+ message_id: string;
319
+ /** The provider that issued it, e.g. "resend" or "brevo". */
320
+ provider: string;
321
+ }
322
+
323
+ namespace email {
324
+ /**
325
+ * Send one transactional email through the tenant's configured provider.
326
+ *
327
+ * Every recipient must be allowed by the function's `email_policy`
328
+ * (`{ enabled, allowed_recipients }` in its `.node.yaml`, matched against
329
+ * the recipient DOMAIN); with no block declared the function cannot send,
330
+ * and one disallowed recipient rejects the whole message.
331
+ *
332
+ * Also rejects when email is not configured or not enabled for the tenant,
333
+ * when the function's `secret_policy` does not grant the credential the
334
+ * config references, or when the provider refuses the message.
335
+ */
336
+ function send(message: EmailMessage): Promise<EmailReceipt>;
337
+ }
338
+
301
339
  namespace events {
302
340
  function emit(eventType: string, data: any): Promise<void>;
303
341
  }