zitejs 0.9.152 → 0.9.153

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.
@@ -45,6 +45,7 @@ declare const FIELDS_BY_TYPE: {
45
45
  dropbox: readonly string[];
46
46
  zendesk: readonly string[];
47
47
  smartsheet: readonly string[];
48
+ jotform: readonly string[];
48
49
  amazonS3: readonly string[];
49
50
  snowflake: readonly string[];
50
51
  databricks: readonly string[];
@@ -59,6 +59,9 @@ const FIELDS_BY_TYPE = {
59
59
  // Smartsheet's US, EU, AU and Gov regions are separate, and a token is only
60
60
  // valid on its own region's host, so the host travels with it.
61
61
  smartsheet: extras("apiBaseUrl"),
62
+ // A Jotform key only works on the API host of its account's region (US or
63
+ // EU), so the host travels with it.
64
+ jotform: extras("apiBaseUrl"),
62
65
  // The IAM key alone reaches nothing: every call needs the region and the
63
66
  // bucket, and S3-compatible providers need the endpoint too.
64
67
  amazonS3: extras("keyId", "region", "bucket", "endpoint", "pathPrefix"),
@@ -19,6 +19,7 @@ const index_js_1 = require("../index.js");
19
19
  (0, vitest_1.expect)(index_js_1.CREDENTIAL_FIELDS.jira).toEqual(["accessToken", "cloudId", "siteUrl"]);
20
20
  (0, vitest_1.expect)(index_js_1.CREDENTIAL_FIELDS.granola).toEqual(["accessToken"]);
21
21
  (0, vitest_1.expect)(index_js_1.CREDENTIAL_FIELDS.smartsheet).toEqual(["accessToken", "apiBaseUrl"]);
22
+ (0, vitest_1.expect)(index_js_1.CREDENTIAL_FIELDS.jotform).toEqual(["accessToken", "apiBaseUrl"]);
22
23
  });
23
24
  (0, vitest_1.it)("has no type the runtime never serves", () => {
24
25
  for (const type of index_js_1.NON_CREDENTIAL_SERVICE_TYPES) {
@@ -292,7 +292,27 @@ interface SendEmailBaseParams {
292
292
  subject: string;
293
293
  cc?: string[];
294
294
  bcc?: string[];
295
+ /**
296
+ * Where replies go. With Zite's sender it defaults to the app owner's
297
+ * email; with Gmail, Outlook or SMTP replies come back to that mailbox.
298
+ */
295
299
  replyTo?: string;
300
+ /** Sender name for this email, e.g. "Maya at Still Water". The address stays the connected sender's. */
301
+ fromName?: string;
302
+ /**
303
+ * Up to 9 labels kept with the email, e.g. `{ invoiceId: 'inv_42' }`. Names
304
+ * are letters, digits, `_` or `-` (up to 20); values up to 80 characters.
305
+ * Zite's sender only.
306
+ */
307
+ tags?: Record<string, string>;
308
+ /**
309
+ * A key for this send, e.g. `invoice-${invoice.id}`. Repeating it within
310
+ * 24 hours returns the first result instead of sending again; reusing it
311
+ * for a different email is an error.
312
+ */
313
+ idempotencyKey?: string;
314
+ /** The email's language, e.g. 'es' or 'pt-BR'. Defaults to 'en'. */
315
+ lang?: string;
296
316
  /**
297
317
  * Text direction of the email. Use 'rtl' for right-to-left languages
298
318
  * (Hebrew, Arabic) — sets dir="rtl" on the email wrapper and right-aligns
@@ -360,8 +380,36 @@ export interface SendEmailResult {
360
380
  /** Problems that did not stop the send, e.g. an email large enough for Gmail to clip. */
361
381
  warnings?: string[];
362
382
  }
383
+ /** One email's outcome in `Email.sendBatch`, in the order sent. */
384
+ export type SendBatchResult = SendEmailResult | {
385
+ success: false;
386
+ error: string;
387
+ };
388
+ /** Delivery status of an email sent with Zite's sender. */
389
+ export interface EmailStatus {
390
+ messageId: string;
391
+ status: "queued" | "sent" | "delivered" | "bounced";
392
+ /** When it was sent (ISO). */
393
+ sentAt: string;
394
+ /** What happened to it, e.g. 'Delivered', 'Bounced', 'Opened', oldest first. */
395
+ events: {
396
+ type: string;
397
+ at: string;
398
+ recipient?: string;
399
+ }[];
400
+ }
363
401
  export interface EmailClient {
364
402
  send(params: SendEmailParams): Promise<SendEmailResult>;
403
+ /**
404
+ * Sends up to 100 emails, one by one, so one failure doesn't stop the rest.
405
+ * Results come back in the same order.
406
+ */
407
+ sendBatch(emails: SendEmailParams[]): Promise<SendBatchResult[]>;
408
+ /**
409
+ * Delivery status of an email this app sent with Zite's sender. Not
410
+ * available for Gmail, Outlook or SMTP.
411
+ */
412
+ get(messageId: string): Promise<EmailStatus>;
365
413
  }
366
414
  /**
367
415
  * Email client — sends through the Zite email gateway via the runtime SDK
@@ -209,6 +209,12 @@ function createAirtableClient(integrationId, className, implicitParams) {
209
209
  function createEmailClient(integrationId) {
210
210
  return {
211
211
  send: (params) => (0, sdkCall_js_1.getSdkCall)()(integrationId, "Email", "send", params),
212
+ sendBatch: (emails) => (0, sdkCall_js_1.getSdkCall)()(integrationId, "Email", "sendBatch", {
213
+ emails,
214
+ }),
215
+ get: (messageId) => (0, sdkCall_js_1.getSdkCall)()(integrationId, "Email", "get", {
216
+ messageId,
217
+ }),
212
218
  };
213
219
  }
214
220
  var client_js_1 = require("../integrations/client.js");
@@ -31,3 +31,20 @@ const vitest_1 = require("vitest");
31
31
  subject: "Hi",
32
32
  }).not.toExtend();
33
33
  });
34
+ (0, vitest_1.test)("an email takes a sender name, tags, an idempotency key and a language", () => {
35
+ (0, vitest_1.expectTypeOf)({
36
+ to: "a@example.com",
37
+ subject: "Invoice",
38
+ html: "<p>Hi</p>",
39
+ fromName: "Maya at Still Water",
40
+ tags: { invoiceId: "inv_42" },
41
+ idempotencyKey: "invoice-42",
42
+ lang: "pt-BR",
43
+ }).toExtend();
44
+ (0, vitest_1.expectTypeOf)({
45
+ to: "a@example.com",
46
+ subject: "Invoice",
47
+ html: "<p>Hi</p>",
48
+ tags: { invoiceId: 42 },
49
+ }).not.toExtend();
50
+ });
@@ -1405,11 +1405,16 @@ function generateEmailSdk(integrationId) {
1405
1405
  "// keep working.",
1406
1406
  "//",
1407
1407
  "// RTL languages (Hebrew, Arabic): pass direction: 'rtl'.",
1408
+ "//",
1409
+ "// await Email.sendBatch([...]) // up to 100, results in order",
1410
+ "// await Email.get(messageId) // delivery status (Zite's sender only)",
1408
1411
  "",
1409
1412
  "import { createEmailClient } from 'zitejs/runtime';",
1410
1413
  "",
1411
1414
  "export type {",
1412
1415
  " EmailBlock,",
1416
+ " EmailStatus,",
1417
+ " SendBatchResult,",
1413
1418
  " SendBlocksEmailParams,",
1414
1419
  " SendEmailParams,",
1415
1420
  " SendEmailResult,",
@@ -45,6 +45,7 @@ declare const FIELDS_BY_TYPE: {
45
45
  dropbox: readonly string[];
46
46
  zendesk: readonly string[];
47
47
  smartsheet: readonly string[];
48
+ jotform: readonly string[];
48
49
  amazonS3: readonly string[];
49
50
  snowflake: readonly string[];
50
51
  databricks: readonly string[];
@@ -56,6 +56,9 @@ const FIELDS_BY_TYPE = {
56
56
  // Smartsheet's US, EU, AU and Gov regions are separate, and a token is only
57
57
  // valid on its own region's host, so the host travels with it.
58
58
  smartsheet: extras("apiBaseUrl"),
59
+ // A Jotform key only works on the API host of its account's region (US or
60
+ // EU), so the host travels with it.
61
+ jotform: extras("apiBaseUrl"),
59
62
  // The IAM key alone reaches nothing: every call needs the region and the
60
63
  // bucket, and S3-compatible providers need the endpoint too.
61
64
  amazonS3: extras("keyId", "region", "bucket", "endpoint", "pathPrefix"),
@@ -17,6 +17,7 @@ describe("CREDENTIAL_FIELDS", () => {
17
17
  expect(CREDENTIAL_FIELDS.jira).toEqual(["accessToken", "cloudId", "siteUrl"]);
18
18
  expect(CREDENTIAL_FIELDS.granola).toEqual(["accessToken"]);
19
19
  expect(CREDENTIAL_FIELDS.smartsheet).toEqual(["accessToken", "apiBaseUrl"]);
20
+ expect(CREDENTIAL_FIELDS.jotform).toEqual(["accessToken", "apiBaseUrl"]);
20
21
  });
21
22
  it("has no type the runtime never serves", () => {
22
23
  for (const type of NON_CREDENTIAL_SERVICE_TYPES) {
@@ -292,7 +292,27 @@ interface SendEmailBaseParams {
292
292
  subject: string;
293
293
  cc?: string[];
294
294
  bcc?: string[];
295
+ /**
296
+ * Where replies go. With Zite's sender it defaults to the app owner's
297
+ * email; with Gmail, Outlook or SMTP replies come back to that mailbox.
298
+ */
295
299
  replyTo?: string;
300
+ /** Sender name for this email, e.g. "Maya at Still Water". The address stays the connected sender's. */
301
+ fromName?: string;
302
+ /**
303
+ * Up to 9 labels kept with the email, e.g. `{ invoiceId: 'inv_42' }`. Names
304
+ * are letters, digits, `_` or `-` (up to 20); values up to 80 characters.
305
+ * Zite's sender only.
306
+ */
307
+ tags?: Record<string, string>;
308
+ /**
309
+ * A key for this send, e.g. `invoice-${invoice.id}`. Repeating it within
310
+ * 24 hours returns the first result instead of sending again; reusing it
311
+ * for a different email is an error.
312
+ */
313
+ idempotencyKey?: string;
314
+ /** The email's language, e.g. 'es' or 'pt-BR'. Defaults to 'en'. */
315
+ lang?: string;
296
316
  /**
297
317
  * Text direction of the email. Use 'rtl' for right-to-left languages
298
318
  * (Hebrew, Arabic) — sets dir="rtl" on the email wrapper and right-aligns
@@ -360,8 +380,36 @@ export interface SendEmailResult {
360
380
  /** Problems that did not stop the send, e.g. an email large enough for Gmail to clip. */
361
381
  warnings?: string[];
362
382
  }
383
+ /** One email's outcome in `Email.sendBatch`, in the order sent. */
384
+ export type SendBatchResult = SendEmailResult | {
385
+ success: false;
386
+ error: string;
387
+ };
388
+ /** Delivery status of an email sent with Zite's sender. */
389
+ export interface EmailStatus {
390
+ messageId: string;
391
+ status: "queued" | "sent" | "delivered" | "bounced";
392
+ /** When it was sent (ISO). */
393
+ sentAt: string;
394
+ /** What happened to it, e.g. 'Delivered', 'Bounced', 'Opened', oldest first. */
395
+ events: {
396
+ type: string;
397
+ at: string;
398
+ recipient?: string;
399
+ }[];
400
+ }
363
401
  export interface EmailClient {
364
402
  send(params: SendEmailParams): Promise<SendEmailResult>;
403
+ /**
404
+ * Sends up to 100 emails, one by one, so one failure doesn't stop the rest.
405
+ * Results come back in the same order.
406
+ */
407
+ sendBatch(emails: SendEmailParams[]): Promise<SendBatchResult[]>;
408
+ /**
409
+ * Delivery status of an email this app sent with Zite's sender. Not
410
+ * available for Gmail, Outlook or SMTP.
411
+ */
412
+ get(messageId: string): Promise<EmailStatus>;
365
413
  }
366
414
  /**
367
415
  * Email client — sends through the Zite email gateway via the runtime SDK
@@ -201,6 +201,12 @@ export function createAirtableClient(integrationId, className, implicitParams) {
201
201
  export function createEmailClient(integrationId) {
202
202
  return {
203
203
  send: (params) => getSdkCall()(integrationId, "Email", "send", params),
204
+ sendBatch: (emails) => getSdkCall()(integrationId, "Email", "sendBatch", {
205
+ emails,
206
+ }),
207
+ get: (messageId) => getSdkCall()(integrationId, "Email", "get", {
208
+ messageId,
209
+ }),
204
210
  };
205
211
  }
206
212
  export { createIntegrationsClient, } from "../integrations/client.js";
@@ -29,3 +29,20 @@ test("an email is written as html or as blocks, not both", () => {
29
29
  subject: "Hi",
30
30
  }).not.toExtend();
31
31
  });
32
+ test("an email takes a sender name, tags, an idempotency key and a language", () => {
33
+ expectTypeOf({
34
+ to: "a@example.com",
35
+ subject: "Invoice",
36
+ html: "<p>Hi</p>",
37
+ fromName: "Maya at Still Water",
38
+ tags: { invoiceId: "inv_42" },
39
+ idempotencyKey: "invoice-42",
40
+ lang: "pt-BR",
41
+ }).toExtend();
42
+ expectTypeOf({
43
+ to: "a@example.com",
44
+ subject: "Invoice",
45
+ html: "<p>Hi</p>",
46
+ tags: { invoiceId: 42 },
47
+ }).not.toExtend();
48
+ });
@@ -1390,11 +1390,16 @@ export function generateEmailSdk(integrationId) {
1390
1390
  "// keep working.",
1391
1391
  "//",
1392
1392
  "// RTL languages (Hebrew, Arabic): pass direction: 'rtl'.",
1393
+ "//",
1394
+ "// await Email.sendBatch([...]) // up to 100, results in order",
1395
+ "// await Email.get(messageId) // delivery status (Zite's sender only)",
1393
1396
  "",
1394
1397
  "import { createEmailClient } from 'zitejs/runtime';",
1395
1398
  "",
1396
1399
  "export type {",
1397
1400
  " EmailBlock,",
1401
+ " EmailStatus,",
1402
+ " SendBatchResult,",
1398
1403
  " SendBlocksEmailParams,",
1399
1404
  " SendEmailParams,",
1400
1405
  " SendEmailResult,",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.9.152",
3
+ "version": "0.9.153",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "sideEffects": false,