resend 6.10.0-preview-workflows.4 → 6.10.0-preview-workflows.6

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/index.cjs CHANGED
@@ -25,7 +25,7 @@ let postal_mime = require("postal-mime");
25
25
  postal_mime = __toESM(postal_mime);
26
26
  let svix = require("svix");
27
27
  //#region package.json
28
- var version = "6.10.0-preview-workflows.4";
28
+ var version = "6.10.0-preview-workflows.6";
29
29
  //#endregion
30
30
  //#region src/common/utils/build-pagination-query.ts
31
31
  /**
@@ -59,33 +59,23 @@ var ApiKeys = class {
59
59
  }
60
60
  };
61
61
  //#endregion
62
- //#region src/automation-run-steps/automation-run-steps.ts
63
- var AutomationRunSteps = class {
64
- constructor(resend) {
65
- this.resend = resend;
66
- }
67
- async get(options) {
68
- return await this.resend.get(`/automations/${options.automationId}/runs/${options.runId}/steps/${options.stepId}`);
69
- }
70
- async list(options) {
71
- const queryString = buildPaginationQuery(options);
72
- const url = queryString ? `/automations/${options.automationId}/runs/${options.runId}/steps?${queryString}` : `/automations/${options.automationId}/runs/${options.runId}/steps`;
73
- return await this.resend.get(url);
74
- }
75
- };
76
- //#endregion
77
62
  //#region src/automation-runs/automation-runs.ts
78
63
  var AutomationRuns = class {
79
64
  constructor(resend) {
80
65
  this.resend = resend;
81
- this.steps = new AutomationRunSteps(resend);
82
66
  }
83
67
  async get(options) {
84
68
  return await this.resend.get(`/automations/${options.automationId}/runs/${options.runId}`);
85
69
  }
86
70
  async list(options) {
87
71
  const queryString = buildPaginationQuery(options);
88
- const url = queryString ? `/automations/${options.automationId}/runs?${queryString}` : `/automations/${options.automationId}/runs`;
72
+ const searchParams = new URLSearchParams(queryString);
73
+ if (options.status) {
74
+ const statusValue = Array.isArray(options.status) ? options.status.join(",") : options.status;
75
+ searchParams.set("status", statusValue);
76
+ }
77
+ const qs = searchParams.toString();
78
+ const url = qs ? `/automations/${options.automationId}/runs?${qs}` : `/automations/${options.automationId}/runs`;
89
79
  return await this.resend.get(url);
90
80
  }
91
81
  };
@@ -94,47 +84,64 @@ var AutomationRuns = class {
94
84
  function parseStepConfig(step) {
95
85
  switch (step.type) {
96
86
  case "trigger": return {
97
- ref: step.ref,
87
+ key: step.key,
98
88
  type: step.type,
99
89
  config: { event_name: step.config.eventName }
100
90
  };
101
91
  case "delay": return {
102
- ref: step.ref,
92
+ key: step.key,
103
93
  type: step.type,
104
94
  config: step.config
105
95
  };
106
96
  case "send_email": return {
107
- ref: step.ref,
97
+ key: step.key,
108
98
  type: step.type,
109
99
  config: {
110
- template_id: step.config.templateId,
100
+ template: {
101
+ id: step.config.templateId,
102
+ variables: step.config.variables
103
+ },
111
104
  subject: step.config.subject,
112
105
  from: step.config.from,
113
- reply_to: step.config.replyTo,
114
- variables: step.config.variables
106
+ reply_to: step.config.replyTo
115
107
  }
116
108
  };
117
109
  case "wait_for_event": return {
118
- ref: step.ref,
110
+ key: step.key,
119
111
  type: step.type,
120
112
  config: {
121
113
  event_name: step.config.eventName,
122
- timeout_seconds: step.config.timeoutSeconds,
114
+ timeout: step.config.timeout,
123
115
  filter_rule: step.config.filterRule
124
116
  }
125
117
  };
126
118
  case "condition": return {
127
- ref: step.ref,
119
+ key: step.key,
120
+ type: step.type,
121
+ config: step.config
122
+ };
123
+ case "contact_update": return {
124
+ key: step.key,
125
+ type: step.type,
126
+ config: step.config
127
+ };
128
+ case "contact_delete": return {
129
+ key: step.key,
130
+ type: step.type,
131
+ config: step.config
132
+ };
133
+ case "add_to_segment": return {
134
+ key: step.key,
128
135
  type: step.type,
129
136
  config: step.config
130
137
  };
131
138
  }
132
139
  }
133
- function parseEdge(edge) {
140
+ function parseConnection(connection) {
134
141
  return {
135
- from: edge.from,
136
- to: edge.to,
137
- edge_type: edge.edgeType
142
+ from: connection.from,
143
+ to: connection.to,
144
+ type: connection.type
138
145
  };
139
146
  }
140
147
  function parseAutomationToApiOptions(automation) {
@@ -142,7 +149,7 @@ function parseAutomationToApiOptions(automation) {
142
149
  name: automation.name,
143
150
  status: automation.status,
144
151
  steps: automation.steps.map(parseStepConfig),
145
- edges: automation.edges.map(parseEdge)
152
+ connections: automation.connections.map(parseConnection)
146
153
  };
147
154
  }
148
155
  function parseEventToApiOptions(event) {
@@ -164,8 +171,10 @@ var Automations = class {
164
171
  return await this.resend.post("/automations", parseAutomationToApiOptions(payload));
165
172
  }
166
173
  async list(options = {}) {
167
- const queryString = buildPaginationQuery(options);
168
- const url = queryString ? `/automations?${queryString}` : "/automations";
174
+ const params = [buildPaginationQuery(options)];
175
+ if (options.status) params.push(`status=${encodeURIComponent(options.status)}`);
176
+ const qs = params.filter(Boolean).join("&");
177
+ const url = qs ? `/automations?${qs}` : "/automations";
169
178
  return await this.resend.get(url);
170
179
  }
171
180
  async get(id) {
@@ -175,7 +184,15 @@ var Automations = class {
175
184
  return await this.resend.delete(`/automations/${id}`);
176
185
  }
177
186
  async update(id, payload) {
178
- return await this.resend.patch(`/automations/${id}`, payload);
187
+ const apiPayload = {};
188
+ if (payload.name !== void 0) apiPayload.name = payload.name;
189
+ if (payload.status !== void 0) apiPayload.status = payload.status;
190
+ if (payload.steps !== void 0) apiPayload.steps = payload.steps.map(parseStepConfig);
191
+ if (payload.connections !== void 0) apiPayload.connections = payload.connections.map(parseConnection);
192
+ return await this.resend.patch(`/automations/${id}`, apiPayload);
193
+ }
194
+ async stop(id) {
195
+ return await this.resend.post(`/automations/${id}/stop`);
179
196
  }
180
197
  };
181
198
  //#endregion
package/dist/index.d.cts CHANGED
@@ -269,7 +269,7 @@ interface TriggerStepConfig {
269
269
  eventName: string;
270
270
  }
271
271
  interface DelayStepConfig {
272
- seconds: number;
272
+ duration: string;
273
273
  }
274
274
  interface SendEmailStepConfig {
275
275
  templateId: string;
@@ -280,98 +280,102 @@ interface SendEmailStepConfig {
280
280
  }
281
281
  interface WaitForEventStepConfig {
282
282
  eventName: string;
283
- timeoutSeconds?: number;
283
+ timeout?: string;
284
284
  filterRule?: ConditionRule;
285
285
  }
286
286
  type ConditionStepConfig = ConditionRule;
287
+ interface ContactUpdateStepConfig {
288
+ first_name?: string | null | {
289
+ var: string;
290
+ };
291
+ last_name?: string | null | {
292
+ var: string;
293
+ };
294
+ unsubscribed?: boolean | {
295
+ var: string;
296
+ };
297
+ properties?: Record<string, string | number | boolean | null | {
298
+ var: string;
299
+ }>;
300
+ }
301
+ type ContactDeleteStepConfig = Record<string, never>;
302
+ interface AddToSegmentStepConfig {
303
+ segment_id: string;
304
+ }
287
305
  type AutomationStep = {
288
- ref: string;
306
+ key: string;
289
307
  type: 'trigger';
290
308
  config: TriggerStepConfig;
291
309
  } | {
292
- ref: string;
310
+ key: string;
293
311
  type: 'delay';
294
312
  config: DelayStepConfig;
295
313
  } | {
296
- ref: string;
314
+ key: string;
297
315
  type: 'send_email';
298
316
  config: SendEmailStepConfig;
299
317
  } | {
300
- ref: string;
318
+ key: string;
301
319
  type: 'wait_for_event';
302
320
  config: WaitForEventStepConfig;
303
321
  } | {
304
- ref: string;
322
+ key: string;
305
323
  type: 'condition';
306
324
  config: ConditionStepConfig;
325
+ } | {
326
+ key: string;
327
+ type: 'contact_update';
328
+ config: ContactUpdateStepConfig;
329
+ } | {
330
+ key: string;
331
+ type: 'contact_delete';
332
+ config: ContactDeleteStepConfig;
333
+ } | {
334
+ key: string;
335
+ type: 'add_to_segment';
336
+ config: AddToSegmentStepConfig;
307
337
  };
308
- type AutomationEdgeType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
309
- interface AutomationEdge {
338
+ type AutomationConnectionType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
339
+ interface AutomationConnection {
310
340
  from: string;
311
341
  to: string;
312
- edgeType?: AutomationEdgeType;
342
+ type?: AutomationConnectionType;
313
343
  }
314
344
  type AutomationStepType = AutomationStep['type'];
315
345
  interface AutomationResponseStep {
316
- id: string;
346
+ key: string;
317
347
  type: AutomationStepType;
318
348
  config: Record<string, unknown>;
319
349
  }
320
- interface AutomationResponseEdge {
321
- id: string;
322
- from_step_id: string;
323
- to_step_id: string;
324
- edge_type: AutomationEdgeType;
350
+ interface AutomationResponseConnection {
351
+ from: string;
352
+ to: string;
353
+ type: AutomationConnectionType;
325
354
  }
326
355
  //#endregion
327
- //#region src/automation-run-steps/interfaces/automation-run-step.d.ts
356
+ //#region src/automation-runs/interfaces/automation-run.d.ts
357
+ type AutomationRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
328
358
  type AutomationRunStepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped' | 'waiting';
329
359
  interface AutomationRunStep {
330
- object: 'automation_run_step';
331
- id: string;
332
- step_id: string;
360
+ key: string;
333
361
  type: AutomationStepType;
334
- config: Record<string, unknown>;
335
362
  status: AutomationRunStepStatus;
363
+ output: Record<string, unknown> | null;
364
+ error: Record<string, unknown> | null;
336
365
  started_at: string | null;
337
366
  completed_at: string | null;
338
367
  created_at: string;
339
368
  }
340
- type AutomationRunStepItem = Pick<AutomationRunStep, 'id' | 'step_id' | 'type' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
341
- //#endregion
342
- //#region src/automation-run-steps/interfaces/get-automation-run-step.interface.d.ts
343
- interface GetAutomationRunStepOptions {
344
- automationId: string;
345
- runId: string;
346
- stepId: string;
347
- }
348
- type GetAutomationRunStepResponseSuccess = AutomationRunStep;
349
- type GetAutomationRunStepResponse = Response<GetAutomationRunStepResponseSuccess>;
350
- //#endregion
351
- //#region src/automation-run-steps/interfaces/list-automation-run-steps.interface.d.ts
352
- type ListAutomationRunStepsOptions = PaginationOptions & {
353
- automationId: string;
354
- runId: string;
355
- };
356
- type ListAutomationRunStepsResponseSuccess = PaginatedData<AutomationRunStepItem[]>;
357
- type ListAutomationRunStepsResponse = Response<ListAutomationRunStepsResponseSuccess>;
358
- //#endregion
359
- //#region src/automation-runs/interfaces/automation-run.d.ts
360
- interface AutomationRunTrigger {
361
- event_name: string;
362
- payload?: Record<string, unknown>;
363
- }
364
- type AutomationRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
365
369
  interface AutomationRun {
366
370
  object: 'automation_run';
367
371
  id: string;
368
372
  status: AutomationRunStatus;
369
- trigger: AutomationRunTrigger | null;
370
373
  started_at: string | null;
371
374
  completed_at: string | null;
372
375
  created_at: string;
376
+ steps: AutomationRunStep[];
373
377
  }
374
- type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | 'trigger' | 'started_at' | 'completed_at' | 'created_at'>;
378
+ type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
375
379
  //#endregion
376
380
  //#region src/automation-runs/interfaces/get-automation-run.interface.d.ts
377
381
  interface GetAutomationRunOptions {
@@ -384,6 +388,7 @@ type GetAutomationRunResponse = Response<GetAutomationRunResponseSuccess>;
384
388
  //#region src/automation-runs/interfaces/list-automation-runs.interface.d.ts
385
389
  type ListAutomationRunsOptions = PaginationOptions & {
386
390
  automationId: string;
391
+ status?: AutomationRunStatus | AutomationRunStatus[];
387
392
  };
388
393
  type ListAutomationRunsResponseSuccess = PaginatedData<AutomationRunItem[]>;
389
394
  type ListAutomationRunsResponse = Response<ListAutomationRunsResponseSuccess>;
@@ -403,7 +408,7 @@ interface CreateAutomationOptions {
403
408
  name: string;
404
409
  status?: AutomationStatus;
405
410
  steps: AutomationStep[];
406
- edges: AutomationEdge[];
411
+ connections: AutomationConnection[];
407
412
  }
408
413
  interface CreateAutomationResponseSuccess {
409
414
  object: 'automation';
@@ -415,12 +420,14 @@ type CreateAutomationResponse = Response<CreateAutomationResponseSuccess>;
415
420
  interface GetAutomationResponseSuccess extends Automation {
416
421
  object: 'automation';
417
422
  steps: AutomationResponseStep[];
418
- edges: AutomationResponseEdge[];
423
+ connections: AutomationResponseConnection[];
419
424
  }
420
425
  type GetAutomationResponse = Response<GetAutomationResponseSuccess>;
421
426
  //#endregion
422
427
  //#region src/automations/interfaces/list-automation.interface.d.ts
423
- type ListAutomationsOptions = PaginationOptions;
428
+ type ListAutomationsOptions = PaginationOptions & {
429
+ status?: AutomationStatus;
430
+ };
424
431
  type ListAutomationsResponseSuccess = PaginatedData<Automation[]>;
425
432
  type ListAutomationsResponse = Response<ListAutomationsResponseSuccess>;
426
433
  //#endregion
@@ -431,11 +438,22 @@ interface RemoveAutomationResponseSuccess extends Pick<Automation, 'id'> {
431
438
  }
432
439
  type RemoveAutomationResponse = Response<RemoveAutomationResponseSuccess>;
433
440
  //#endregion
441
+ //#region src/automations/interfaces/stop-automation.interface.d.ts
442
+ interface StopAutomationResponseSuccess {
443
+ object: 'automation';
444
+ id: string;
445
+ status: 'disabled';
446
+ }
447
+ type StopAutomationResponse = Response<StopAutomationResponseSuccess>;
448
+ //#endregion
434
449
  //#region src/automations/interfaces/update-automation.interface.d.ts
435
450
  interface UpdateAutomationOptions {
436
- status: AutomationStatus;
451
+ name?: string;
452
+ status?: AutomationStatus;
453
+ steps?: AutomationStep[];
454
+ connections?: AutomationConnection[];
437
455
  }
438
- interface UpdateAutomationResponseSuccess extends Pick<Automation, 'id' | 'status'> {
456
+ interface UpdateAutomationResponseSuccess extends Pick<Automation, 'id'> {
439
457
  object: 'automation';
440
458
  }
441
459
  type UpdateAutomationResponse = Response<UpdateAutomationResponseSuccess>;
@@ -1429,18 +1447,9 @@ declare class ApiKeys {
1429
1447
  remove(id: string): Promise<RemoveApiKeyResponse>;
1430
1448
  }
1431
1449
  //#endregion
1432
- //#region src/automation-run-steps/automation-run-steps.d.ts
1433
- declare class AutomationRunSteps {
1434
- private readonly resend;
1435
- constructor(resend: Resend);
1436
- get(options: GetAutomationRunStepOptions): Promise<GetAutomationRunStepResponse>;
1437
- list(options: ListAutomationRunStepsOptions): Promise<ListAutomationRunStepsResponse>;
1438
- }
1439
- //#endregion
1440
1450
  //#region src/automation-runs/automation-runs.d.ts
1441
1451
  declare class AutomationRuns {
1442
1452
  private readonly resend;
1443
- readonly steps: AutomationRunSteps;
1444
1453
  constructor(resend: Resend);
1445
1454
  get(options: GetAutomationRunOptions): Promise<GetAutomationRunResponse>;
1446
1455
  list(options: ListAutomationRunsOptions): Promise<ListAutomationRunsResponse>;
@@ -1456,6 +1465,7 @@ declare class Automations {
1456
1465
  get(id: string): Promise<GetAutomationResponse>;
1457
1466
  remove(id: string): Promise<RemoveAutomationResponse>;
1458
1467
  update(id: string, payload: UpdateAutomationOptions): Promise<UpdateAutomationResponse>;
1468
+ stop(id: string): Promise<StopAutomationResponse>;
1459
1469
  }
1460
1470
  //#endregion
1461
1471
  //#region src/batch/batch.d.ts
@@ -2104,4 +2114,4 @@ declare class Resend {
2104
2114
  delete<T>(path: string, query?: unknown): Promise<Response<T>>;
2105
2115
  }
2106
2116
  //#endregion
2107
- export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation, AutomationEdge, AutomationEdgeType, AutomationResponseEdge, AutomationResponseStep, AutomationRun, AutomationRunItem, AutomationRunStatus, AutomationRunStep, AutomationRunStepItem, AutomationRunStepStatus, AutomationRunTrigger, AutomationStatus, AutomationStep, AutomationStepType, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAutomationOptions, CreateAutomationResponse, CreateAutomationResponseSuccess, CreateBatchEmailOptions, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateEventOptions, CreateEventResponse, CreateEventResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DelayStepConfig, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, Event, EventSchemaMap, EventSchemaType, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetAutomationResponse, GetAutomationResponseSuccess, GetAutomationRunOptions, GetAutomationRunResponse, GetAutomationRunResponseSuccess, GetAutomationRunStepOptions, GetAutomationRunStepResponse, GetAutomationRunStepResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetLogResponse, GetLogResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListAutomationRunStepsOptions, ListAutomationRunStepsResponse, ListAutomationRunStepsResponseSuccess, ListAutomationRunsOptions, ListAutomationRunsResponse, ListAutomationRunsResponseSuccess, ListAutomationsOptions, ListAutomationsResponse, ListAutomationsResponseSuccess, ListBroadcastsOptions, ListBroadcastsResponse, ListBroadcastsResponseSuccess, ListContactPropertiesOptions, ListContactPropertiesResponse, ListContactPropertiesResponseSuccess, ListContactSegmentsOptions, ListContactSegmentsResponse, ListContactSegmentsResponseSuccess, ListContactTopicsOptions, ListContactTopicsRequestOptions, ListContactTopicsResponse, ListContactTopicsResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsOptions, ListDomainsResponse, ListDomainsResponseSuccess, ListEmail, ListEmailsOptions, ListEmailsResponse, ListEmailsResponseSuccess, ListEventsOptions, ListEventsResponse, ListEventsResponseSuccess, ListLogsOptions, ListLogsResponse, ListLogsResponseSuccess, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, Log, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAutomationResponse, RemoveAutomationResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TriggerStepConfig, UpdateAutomationOptions, UpdateAutomationResponse, UpdateAutomationResponseSuccess, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateEventOptions, UpdateEventResponse, UpdateEventResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload };
2117
+ export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, AddToSegmentStepConfig, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation, AutomationConnection, AutomationConnectionType, AutomationResponseConnection, AutomationResponseStep, AutomationRun, AutomationRunItem, AutomationRunStatus, AutomationRunStep, AutomationRunStepStatus, AutomationStatus, AutomationStep, AutomationStepType, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeleteStepConfig, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdateStepConfig, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAutomationOptions, CreateAutomationResponse, CreateAutomationResponseSuccess, CreateBatchEmailOptions, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateEventOptions, CreateEventResponse, CreateEventResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DelayStepConfig, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, Event, EventSchemaMap, EventSchemaType, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetAutomationResponse, GetAutomationResponseSuccess, GetAutomationRunOptions, GetAutomationRunResponse, GetAutomationRunResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetLogResponse, GetLogResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListAutomationRunsOptions, ListAutomationRunsResponse, ListAutomationRunsResponseSuccess, ListAutomationsOptions, ListAutomationsResponse, ListAutomationsResponseSuccess, ListBroadcastsOptions, ListBroadcastsResponse, ListBroadcastsResponseSuccess, ListContactPropertiesOptions, ListContactPropertiesResponse, ListContactPropertiesResponseSuccess, ListContactSegmentsOptions, ListContactSegmentsResponse, ListContactSegmentsResponseSuccess, ListContactTopicsOptions, ListContactTopicsRequestOptions, ListContactTopicsResponse, ListContactTopicsResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsOptions, ListDomainsResponse, ListDomainsResponseSuccess, ListEmail, ListEmailsOptions, ListEmailsResponse, ListEmailsResponseSuccess, ListEventsOptions, ListEventsResponse, ListEventsResponseSuccess, ListLogsOptions, ListLogsResponse, ListLogsResponseSuccess, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, Log, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAutomationResponse, RemoveAutomationResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, StopAutomationResponse, StopAutomationResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TriggerStepConfig, UpdateAutomationOptions, UpdateAutomationResponse, UpdateAutomationResponseSuccess, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateEventOptions, UpdateEventResponse, UpdateEventResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload };
package/dist/index.d.mts CHANGED
@@ -269,7 +269,7 @@ interface TriggerStepConfig {
269
269
  eventName: string;
270
270
  }
271
271
  interface DelayStepConfig {
272
- seconds: number;
272
+ duration: string;
273
273
  }
274
274
  interface SendEmailStepConfig {
275
275
  templateId: string;
@@ -280,98 +280,102 @@ interface SendEmailStepConfig {
280
280
  }
281
281
  interface WaitForEventStepConfig {
282
282
  eventName: string;
283
- timeoutSeconds?: number;
283
+ timeout?: string;
284
284
  filterRule?: ConditionRule;
285
285
  }
286
286
  type ConditionStepConfig = ConditionRule;
287
+ interface ContactUpdateStepConfig {
288
+ first_name?: string | null | {
289
+ var: string;
290
+ };
291
+ last_name?: string | null | {
292
+ var: string;
293
+ };
294
+ unsubscribed?: boolean | {
295
+ var: string;
296
+ };
297
+ properties?: Record<string, string | number | boolean | null | {
298
+ var: string;
299
+ }>;
300
+ }
301
+ type ContactDeleteStepConfig = Record<string, never>;
302
+ interface AddToSegmentStepConfig {
303
+ segment_id: string;
304
+ }
287
305
  type AutomationStep = {
288
- ref: string;
306
+ key: string;
289
307
  type: 'trigger';
290
308
  config: TriggerStepConfig;
291
309
  } | {
292
- ref: string;
310
+ key: string;
293
311
  type: 'delay';
294
312
  config: DelayStepConfig;
295
313
  } | {
296
- ref: string;
314
+ key: string;
297
315
  type: 'send_email';
298
316
  config: SendEmailStepConfig;
299
317
  } | {
300
- ref: string;
318
+ key: string;
301
319
  type: 'wait_for_event';
302
320
  config: WaitForEventStepConfig;
303
321
  } | {
304
- ref: string;
322
+ key: string;
305
323
  type: 'condition';
306
324
  config: ConditionStepConfig;
325
+ } | {
326
+ key: string;
327
+ type: 'contact_update';
328
+ config: ContactUpdateStepConfig;
329
+ } | {
330
+ key: string;
331
+ type: 'contact_delete';
332
+ config: ContactDeleteStepConfig;
333
+ } | {
334
+ key: string;
335
+ type: 'add_to_segment';
336
+ config: AddToSegmentStepConfig;
307
337
  };
308
- type AutomationEdgeType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
309
- interface AutomationEdge {
338
+ type AutomationConnectionType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
339
+ interface AutomationConnection {
310
340
  from: string;
311
341
  to: string;
312
- edgeType?: AutomationEdgeType;
342
+ type?: AutomationConnectionType;
313
343
  }
314
344
  type AutomationStepType = AutomationStep['type'];
315
345
  interface AutomationResponseStep {
316
- id: string;
346
+ key: string;
317
347
  type: AutomationStepType;
318
348
  config: Record<string, unknown>;
319
349
  }
320
- interface AutomationResponseEdge {
321
- id: string;
322
- from_step_id: string;
323
- to_step_id: string;
324
- edge_type: AutomationEdgeType;
350
+ interface AutomationResponseConnection {
351
+ from: string;
352
+ to: string;
353
+ type: AutomationConnectionType;
325
354
  }
326
355
  //#endregion
327
- //#region src/automation-run-steps/interfaces/automation-run-step.d.ts
356
+ //#region src/automation-runs/interfaces/automation-run.d.ts
357
+ type AutomationRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
328
358
  type AutomationRunStepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped' | 'waiting';
329
359
  interface AutomationRunStep {
330
- object: 'automation_run_step';
331
- id: string;
332
- step_id: string;
360
+ key: string;
333
361
  type: AutomationStepType;
334
- config: Record<string, unknown>;
335
362
  status: AutomationRunStepStatus;
363
+ output: Record<string, unknown> | null;
364
+ error: Record<string, unknown> | null;
336
365
  started_at: string | null;
337
366
  completed_at: string | null;
338
367
  created_at: string;
339
368
  }
340
- type AutomationRunStepItem = Pick<AutomationRunStep, 'id' | 'step_id' | 'type' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
341
- //#endregion
342
- //#region src/automation-run-steps/interfaces/get-automation-run-step.interface.d.ts
343
- interface GetAutomationRunStepOptions {
344
- automationId: string;
345
- runId: string;
346
- stepId: string;
347
- }
348
- type GetAutomationRunStepResponseSuccess = AutomationRunStep;
349
- type GetAutomationRunStepResponse = Response<GetAutomationRunStepResponseSuccess>;
350
- //#endregion
351
- //#region src/automation-run-steps/interfaces/list-automation-run-steps.interface.d.ts
352
- type ListAutomationRunStepsOptions = PaginationOptions & {
353
- automationId: string;
354
- runId: string;
355
- };
356
- type ListAutomationRunStepsResponseSuccess = PaginatedData<AutomationRunStepItem[]>;
357
- type ListAutomationRunStepsResponse = Response<ListAutomationRunStepsResponseSuccess>;
358
- //#endregion
359
- //#region src/automation-runs/interfaces/automation-run.d.ts
360
- interface AutomationRunTrigger {
361
- event_name: string;
362
- payload?: Record<string, unknown>;
363
- }
364
- type AutomationRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
365
369
  interface AutomationRun {
366
370
  object: 'automation_run';
367
371
  id: string;
368
372
  status: AutomationRunStatus;
369
- trigger: AutomationRunTrigger | null;
370
373
  started_at: string | null;
371
374
  completed_at: string | null;
372
375
  created_at: string;
376
+ steps: AutomationRunStep[];
373
377
  }
374
- type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | 'trigger' | 'started_at' | 'completed_at' | 'created_at'>;
378
+ type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
375
379
  //#endregion
376
380
  //#region src/automation-runs/interfaces/get-automation-run.interface.d.ts
377
381
  interface GetAutomationRunOptions {
@@ -384,6 +388,7 @@ type GetAutomationRunResponse = Response<GetAutomationRunResponseSuccess>;
384
388
  //#region src/automation-runs/interfaces/list-automation-runs.interface.d.ts
385
389
  type ListAutomationRunsOptions = PaginationOptions & {
386
390
  automationId: string;
391
+ status?: AutomationRunStatus | AutomationRunStatus[];
387
392
  };
388
393
  type ListAutomationRunsResponseSuccess = PaginatedData<AutomationRunItem[]>;
389
394
  type ListAutomationRunsResponse = Response<ListAutomationRunsResponseSuccess>;
@@ -403,7 +408,7 @@ interface CreateAutomationOptions {
403
408
  name: string;
404
409
  status?: AutomationStatus;
405
410
  steps: AutomationStep[];
406
- edges: AutomationEdge[];
411
+ connections: AutomationConnection[];
407
412
  }
408
413
  interface CreateAutomationResponseSuccess {
409
414
  object: 'automation';
@@ -415,12 +420,14 @@ type CreateAutomationResponse = Response<CreateAutomationResponseSuccess>;
415
420
  interface GetAutomationResponseSuccess extends Automation {
416
421
  object: 'automation';
417
422
  steps: AutomationResponseStep[];
418
- edges: AutomationResponseEdge[];
423
+ connections: AutomationResponseConnection[];
419
424
  }
420
425
  type GetAutomationResponse = Response<GetAutomationResponseSuccess>;
421
426
  //#endregion
422
427
  //#region src/automations/interfaces/list-automation.interface.d.ts
423
- type ListAutomationsOptions = PaginationOptions;
428
+ type ListAutomationsOptions = PaginationOptions & {
429
+ status?: AutomationStatus;
430
+ };
424
431
  type ListAutomationsResponseSuccess = PaginatedData<Automation[]>;
425
432
  type ListAutomationsResponse = Response<ListAutomationsResponseSuccess>;
426
433
  //#endregion
@@ -431,11 +438,22 @@ interface RemoveAutomationResponseSuccess extends Pick<Automation, 'id'> {
431
438
  }
432
439
  type RemoveAutomationResponse = Response<RemoveAutomationResponseSuccess>;
433
440
  //#endregion
441
+ //#region src/automations/interfaces/stop-automation.interface.d.ts
442
+ interface StopAutomationResponseSuccess {
443
+ object: 'automation';
444
+ id: string;
445
+ status: 'disabled';
446
+ }
447
+ type StopAutomationResponse = Response<StopAutomationResponseSuccess>;
448
+ //#endregion
434
449
  //#region src/automations/interfaces/update-automation.interface.d.ts
435
450
  interface UpdateAutomationOptions {
436
- status: AutomationStatus;
451
+ name?: string;
452
+ status?: AutomationStatus;
453
+ steps?: AutomationStep[];
454
+ connections?: AutomationConnection[];
437
455
  }
438
- interface UpdateAutomationResponseSuccess extends Pick<Automation, 'id' | 'status'> {
456
+ interface UpdateAutomationResponseSuccess extends Pick<Automation, 'id'> {
439
457
  object: 'automation';
440
458
  }
441
459
  type UpdateAutomationResponse = Response<UpdateAutomationResponseSuccess>;
@@ -1429,18 +1447,9 @@ declare class ApiKeys {
1429
1447
  remove(id: string): Promise<RemoveApiKeyResponse>;
1430
1448
  }
1431
1449
  //#endregion
1432
- //#region src/automation-run-steps/automation-run-steps.d.ts
1433
- declare class AutomationRunSteps {
1434
- private readonly resend;
1435
- constructor(resend: Resend);
1436
- get(options: GetAutomationRunStepOptions): Promise<GetAutomationRunStepResponse>;
1437
- list(options: ListAutomationRunStepsOptions): Promise<ListAutomationRunStepsResponse>;
1438
- }
1439
- //#endregion
1440
1450
  //#region src/automation-runs/automation-runs.d.ts
1441
1451
  declare class AutomationRuns {
1442
1452
  private readonly resend;
1443
- readonly steps: AutomationRunSteps;
1444
1453
  constructor(resend: Resend);
1445
1454
  get(options: GetAutomationRunOptions): Promise<GetAutomationRunResponse>;
1446
1455
  list(options: ListAutomationRunsOptions): Promise<ListAutomationRunsResponse>;
@@ -1456,6 +1465,7 @@ declare class Automations {
1456
1465
  get(id: string): Promise<GetAutomationResponse>;
1457
1466
  remove(id: string): Promise<RemoveAutomationResponse>;
1458
1467
  update(id: string, payload: UpdateAutomationOptions): Promise<UpdateAutomationResponse>;
1468
+ stop(id: string): Promise<StopAutomationResponse>;
1459
1469
  }
1460
1470
  //#endregion
1461
1471
  //#region src/batch/batch.d.ts
@@ -2104,4 +2114,4 @@ declare class Resend {
2104
2114
  delete<T>(path: string, query?: unknown): Promise<Response<T>>;
2105
2115
  }
2106
2116
  //#endregion
2107
- export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation, AutomationEdge, AutomationEdgeType, AutomationResponseEdge, AutomationResponseStep, AutomationRun, AutomationRunItem, AutomationRunStatus, AutomationRunStep, AutomationRunStepItem, AutomationRunStepStatus, AutomationRunTrigger, AutomationStatus, AutomationStep, AutomationStepType, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAutomationOptions, CreateAutomationResponse, CreateAutomationResponseSuccess, CreateBatchEmailOptions, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateEventOptions, CreateEventResponse, CreateEventResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DelayStepConfig, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, Event, EventSchemaMap, EventSchemaType, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetAutomationResponse, GetAutomationResponseSuccess, GetAutomationRunOptions, GetAutomationRunResponse, GetAutomationRunResponseSuccess, GetAutomationRunStepOptions, GetAutomationRunStepResponse, GetAutomationRunStepResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetLogResponse, GetLogResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListAutomationRunStepsOptions, ListAutomationRunStepsResponse, ListAutomationRunStepsResponseSuccess, ListAutomationRunsOptions, ListAutomationRunsResponse, ListAutomationRunsResponseSuccess, ListAutomationsOptions, ListAutomationsResponse, ListAutomationsResponseSuccess, ListBroadcastsOptions, ListBroadcastsResponse, ListBroadcastsResponseSuccess, ListContactPropertiesOptions, ListContactPropertiesResponse, ListContactPropertiesResponseSuccess, ListContactSegmentsOptions, ListContactSegmentsResponse, ListContactSegmentsResponseSuccess, ListContactTopicsOptions, ListContactTopicsRequestOptions, ListContactTopicsResponse, ListContactTopicsResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsOptions, ListDomainsResponse, ListDomainsResponseSuccess, ListEmail, ListEmailsOptions, ListEmailsResponse, ListEmailsResponseSuccess, ListEventsOptions, ListEventsResponse, ListEventsResponseSuccess, ListLogsOptions, ListLogsResponse, ListLogsResponseSuccess, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, Log, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAutomationResponse, RemoveAutomationResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TriggerStepConfig, UpdateAutomationOptions, UpdateAutomationResponse, UpdateAutomationResponseSuccess, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateEventOptions, UpdateEventResponse, UpdateEventResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload };
2117
+ export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, AddToSegmentStepConfig, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation, AutomationConnection, AutomationConnectionType, AutomationResponseConnection, AutomationResponseStep, AutomationRun, AutomationRunItem, AutomationRunStatus, AutomationRunStep, AutomationRunStepStatus, AutomationStatus, AutomationStep, AutomationStepType, Broadcast, CancelEmailResponse, CancelEmailResponseSuccess, ConditionRule, ConditionStepConfig, Contact, ContactCreatedEvent, ContactDeleteStepConfig, ContactDeletedEvent, ContactProperty, ContactSegmentsBaseOptions, ContactTopic, ContactUpdateStepConfig, ContactUpdatedEvent, CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse, CreateApiKeyResponseSuccess, CreateAutomationOptions, CreateAutomationResponse, CreateAutomationResponseSuccess, CreateBatchEmailOptions, CreateBatchOptions, CreateBatchRequestOptions, CreateBatchResponse, CreateBatchSuccessResponse, CreateBroadcastOptions, CreateBroadcastRequestOptions, CreateBroadcastResponse, CreateBroadcastResponseSuccess, CreateContactOptions, CreateContactPropertyApiOptions, CreateContactPropertyOptions, CreateContactPropertyResponse, CreateContactPropertyResponseSuccess, CreateContactRequestOptions, CreateContactResponse, CreateContactResponseSuccess, CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse, CreateDomainResponseSuccess, CreateEmailOptions, CreateEmailRequestOptions, CreateEmailResponse, CreateEmailResponseSuccess, CreateEventOptions, CreateEventResponse, CreateEventResponseSuccess, CreateSegmentOptions, CreateSegmentRequestOptions, CreateSegmentResponse, CreateSegmentResponseSuccess, CreateTemplateOptions, CreateTemplateRequestOptions, CreateTemplateResponse, CreateTemplateResponseSuccess, CreateTopicOptions, CreateTopicResponse, CreateTopicResponseSuccess, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DelayStepConfig, Domain, DomainApiOptions, DomainCapabilities, DomainCapabilityStatus, DomainCreatedEvent, DomainDeletedEvent, DomainDkimRecord, DomainNameservers, DomainRecords, DomainRegion, DomainSpfRecord, DomainStatus, DomainUpdatedEvent, DuplicateTemplateResponse, DuplicateTemplateResponseSuccess, EmailApiAttachment, EmailApiOptions, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, type ErrorResponse, Event, EventSchemaMap, EventSchemaType, ForwardReceivingEmailOptions, ForwardReceivingEmailResponse, ForwardReceivingEmailResponseSuccess, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetAutomationResponse, GetAutomationResponseSuccess, GetAutomationRunOptions, GetAutomationRunResponse, GetAutomationRunResponseSuccess, GetBroadcastResponse, GetBroadcastResponseSuccess, GetContactOptions, GetContactPropertyResponse, GetContactPropertyResponseSuccess, GetContactResponse, GetContactResponseSuccess, GetDomainResponse, GetDomainResponseSuccess, GetEmailResponse, GetEmailResponseSuccess, GetEventResponse, GetEventResponseSuccess, GetLogResponse, GetLogResponseSuccess, GetOptions, GetReceivingEmailResponse, GetReceivingEmailResponseSuccess, GetSegmentResponse, GetSegmentResponseSuccess, GetTemplateResponse, GetTemplateResponseSuccess, GetTopicOptions, GetTopicResponse, GetTopicResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, IdempotentRequest, InboundAttachment, LegacyCreateContactOptions, ListApiKeysOptions, ListApiKeysResponse, ListApiKeysResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListAutomationRunsOptions, ListAutomationRunsResponse, ListAutomationRunsResponseSuccess, ListAutomationsOptions, ListAutomationsResponse, ListAutomationsResponseSuccess, ListBroadcastsOptions, ListBroadcastsResponse, ListBroadcastsResponseSuccess, ListContactPropertiesOptions, ListContactPropertiesResponse, ListContactPropertiesResponseSuccess, ListContactSegmentsOptions, ListContactSegmentsResponse, ListContactSegmentsResponseSuccess, ListContactTopicsOptions, ListContactTopicsRequestOptions, ListContactTopicsResponse, ListContactTopicsResponseSuccess, ListContactsOptions, ListContactsResponse, ListContactsResponseSuccess, ListDomainsOptions, ListDomainsResponse, ListDomainsResponseSuccess, ListEmail, ListEmailsOptions, ListEmailsResponse, ListEmailsResponseSuccess, ListEventsOptions, ListEventsResponse, ListEventsResponseSuccess, ListLogsOptions, ListLogsResponse, ListLogsResponseSuccess, ListReceivingEmail, ListReceivingEmailsOptions, ListReceivingEmailsResponse, ListReceivingEmailsResponseSuccess, ListSegmentsOptions, ListSegmentsResponse, ListSegmentsResponseSuccess, ListTemplatesOptions, ListTemplatesResponse, ListTemplatesResponseSuccess, ListTopicsResponse, ListTopicsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, Log, PaginatedData, PaginationOptions, PatchOptions, PostOptions, PublishTemplateResponse, PublishTemplateResponseSuccess, PutOptions, ReceivingRecord, RemoveApiKeyResponse, RemoveApiKeyResponseSuccess, RemoveAutomationResponse, RemoveAutomationResponseSuccess, RemoveBroadcastResponse, RemoveBroadcastResponseSuccess, RemoveContactOptions, RemoveContactPropertyResponse, RemoveContactPropertyResponseSuccess, RemoveContactSegmentOptions, RemoveContactSegmentResponse, RemoveContactSegmentResponseSuccess, RemoveContactsResponse, RemoveContactsResponseSuccess, RemoveDomainsResponse, RemoveDomainsResponseSuccess, RemoveEventResponse, RemoveEventResponseSuccess, RemoveSegmentResponse, RemoveSegmentResponseSuccess, RemoveTemplateResponse, RemoveTemplateResponseSuccess, RemoveTopicResponse, RemoveTopicResponseSuccess, RemoveWebhookResponse, RemoveWebhookResponseSuccess, RequireAtLeastOne, Resend, type Response, Segment, SelectingField, SendBroadcastOptions, SendBroadcastRequestOptions, SendBroadcastResponse, SendBroadcastResponseSuccess, SendEmailStepConfig, SendEventOptions, SendEventResponse, SendEventResponseSuccess, StopAutomationResponse, StopAutomationResponseSuccess, Tag, Template, TemplateVariable, TemplateVariableValue, Topic, TriggerStepConfig, UpdateAutomationOptions, UpdateAutomationResponse, UpdateAutomationResponseSuccess, UpdateBroadcastOptions, UpdateBroadcastResponse, UpdateBroadcastResponseSuccess, UpdateContactOptions, UpdateContactPropertyApiOptions, UpdateContactPropertyOptions, UpdateContactPropertyResponse, UpdateContactPropertyResponseSuccess, UpdateContactResponse, UpdateContactResponseSuccess, UpdateContactTopicsOptions, UpdateContactTopicsRequestOptions, UpdateContactTopicsResponse, UpdateContactTopicsResponseSuccess, UpdateDomainsOptions, UpdateDomainsResponse, UpdateDomainsResponseSuccess, UpdateEmailOptions, UpdateEmailResponse, UpdateEmailResponseSuccess, UpdateEventOptions, UpdateEventResponse, UpdateEventResponseSuccess, UpdateTemplateOptions, UpdateTemplateResponse, UpdateTemplateResponseSuccess, UpdateTopicOptions, UpdateTopicResponse, UpdateTopicResponseSuccess, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, VerifyDomainsResponse, VerifyDomainsResponseSuccess, WaitForEventStepConfig, Webhook, WebhookEvent, WebhookEventPayload };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import PostalMime from "postal-mime";
2
2
  import { Webhook } from "svix";
3
3
  //#region package.json
4
- var version = "6.10.0-preview-workflows.4";
4
+ var version = "6.10.0-preview-workflows.6";
5
5
  //#endregion
6
6
  //#region src/common/utils/build-pagination-query.ts
7
7
  /**
@@ -35,33 +35,23 @@ var ApiKeys = class {
35
35
  }
36
36
  };
37
37
  //#endregion
38
- //#region src/automation-run-steps/automation-run-steps.ts
39
- var AutomationRunSteps = class {
40
- constructor(resend) {
41
- this.resend = resend;
42
- }
43
- async get(options) {
44
- return await this.resend.get(`/automations/${options.automationId}/runs/${options.runId}/steps/${options.stepId}`);
45
- }
46
- async list(options) {
47
- const queryString = buildPaginationQuery(options);
48
- const url = queryString ? `/automations/${options.automationId}/runs/${options.runId}/steps?${queryString}` : `/automations/${options.automationId}/runs/${options.runId}/steps`;
49
- return await this.resend.get(url);
50
- }
51
- };
52
- //#endregion
53
38
  //#region src/automation-runs/automation-runs.ts
54
39
  var AutomationRuns = class {
55
40
  constructor(resend) {
56
41
  this.resend = resend;
57
- this.steps = new AutomationRunSteps(resend);
58
42
  }
59
43
  async get(options) {
60
44
  return await this.resend.get(`/automations/${options.automationId}/runs/${options.runId}`);
61
45
  }
62
46
  async list(options) {
63
47
  const queryString = buildPaginationQuery(options);
64
- const url = queryString ? `/automations/${options.automationId}/runs?${queryString}` : `/automations/${options.automationId}/runs`;
48
+ const searchParams = new URLSearchParams(queryString);
49
+ if (options.status) {
50
+ const statusValue = Array.isArray(options.status) ? options.status.join(",") : options.status;
51
+ searchParams.set("status", statusValue);
52
+ }
53
+ const qs = searchParams.toString();
54
+ const url = qs ? `/automations/${options.automationId}/runs?${qs}` : `/automations/${options.automationId}/runs`;
65
55
  return await this.resend.get(url);
66
56
  }
67
57
  };
@@ -70,47 +60,64 @@ var AutomationRuns = class {
70
60
  function parseStepConfig(step) {
71
61
  switch (step.type) {
72
62
  case "trigger": return {
73
- ref: step.ref,
63
+ key: step.key,
74
64
  type: step.type,
75
65
  config: { event_name: step.config.eventName }
76
66
  };
77
67
  case "delay": return {
78
- ref: step.ref,
68
+ key: step.key,
79
69
  type: step.type,
80
70
  config: step.config
81
71
  };
82
72
  case "send_email": return {
83
- ref: step.ref,
73
+ key: step.key,
84
74
  type: step.type,
85
75
  config: {
86
- template_id: step.config.templateId,
76
+ template: {
77
+ id: step.config.templateId,
78
+ variables: step.config.variables
79
+ },
87
80
  subject: step.config.subject,
88
81
  from: step.config.from,
89
- reply_to: step.config.replyTo,
90
- variables: step.config.variables
82
+ reply_to: step.config.replyTo
91
83
  }
92
84
  };
93
85
  case "wait_for_event": return {
94
- ref: step.ref,
86
+ key: step.key,
95
87
  type: step.type,
96
88
  config: {
97
89
  event_name: step.config.eventName,
98
- timeout_seconds: step.config.timeoutSeconds,
90
+ timeout: step.config.timeout,
99
91
  filter_rule: step.config.filterRule
100
92
  }
101
93
  };
102
94
  case "condition": return {
103
- ref: step.ref,
95
+ key: step.key,
96
+ type: step.type,
97
+ config: step.config
98
+ };
99
+ case "contact_update": return {
100
+ key: step.key,
101
+ type: step.type,
102
+ config: step.config
103
+ };
104
+ case "contact_delete": return {
105
+ key: step.key,
106
+ type: step.type,
107
+ config: step.config
108
+ };
109
+ case "add_to_segment": return {
110
+ key: step.key,
104
111
  type: step.type,
105
112
  config: step.config
106
113
  };
107
114
  }
108
115
  }
109
- function parseEdge(edge) {
116
+ function parseConnection(connection) {
110
117
  return {
111
- from: edge.from,
112
- to: edge.to,
113
- edge_type: edge.edgeType
118
+ from: connection.from,
119
+ to: connection.to,
120
+ type: connection.type
114
121
  };
115
122
  }
116
123
  function parseAutomationToApiOptions(automation) {
@@ -118,7 +125,7 @@ function parseAutomationToApiOptions(automation) {
118
125
  name: automation.name,
119
126
  status: automation.status,
120
127
  steps: automation.steps.map(parseStepConfig),
121
- edges: automation.edges.map(parseEdge)
128
+ connections: automation.connections.map(parseConnection)
122
129
  };
123
130
  }
124
131
  function parseEventToApiOptions(event) {
@@ -140,8 +147,10 @@ var Automations = class {
140
147
  return await this.resend.post("/automations", parseAutomationToApiOptions(payload));
141
148
  }
142
149
  async list(options = {}) {
143
- const queryString = buildPaginationQuery(options);
144
- const url = queryString ? `/automations?${queryString}` : "/automations";
150
+ const params = [buildPaginationQuery(options)];
151
+ if (options.status) params.push(`status=${encodeURIComponent(options.status)}`);
152
+ const qs = params.filter(Boolean).join("&");
153
+ const url = qs ? `/automations?${qs}` : "/automations";
145
154
  return await this.resend.get(url);
146
155
  }
147
156
  async get(id) {
@@ -151,7 +160,15 @@ var Automations = class {
151
160
  return await this.resend.delete(`/automations/${id}`);
152
161
  }
153
162
  async update(id, payload) {
154
- return await this.resend.patch(`/automations/${id}`, payload);
163
+ const apiPayload = {};
164
+ if (payload.name !== void 0) apiPayload.name = payload.name;
165
+ if (payload.status !== void 0) apiPayload.status = payload.status;
166
+ if (payload.steps !== void 0) apiPayload.steps = payload.steps.map(parseStepConfig);
167
+ if (payload.connections !== void 0) apiPayload.connections = payload.connections.map(parseConnection);
168
+ return await this.resend.patch(`/automations/${id}`, apiPayload);
169
+ }
170
+ async stop(id) {
171
+ return await this.resend.post(`/automations/${id}/stop`);
155
172
  }
156
173
  };
157
174
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resend",
3
- "version": "6.10.0-preview-workflows.4",
3
+ "version": "6.10.0-preview-workflows.6",
4
4
  "description": "Node.js library for the Resend API",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -29,19 +29,6 @@
29
29
  }
30
30
  }
31
31
  },
32
- "scripts": {
33
- "build": "tsdown src/index.ts --format esm,cjs --dts",
34
- "integration:nextjs": "cd ./e2e/nextjs && next build --turbopack",
35
- "lint": "biome check .",
36
- "lint:fix": "biome check . --write",
37
- "prepublishOnly": "pnpm run build",
38
- "test": "vitest run --exclude e2e",
39
- "test:dev": "cross-env TEST_MODE=dev vitest run --exclude e2e",
40
- "test:e2e": "vitest run e2e",
41
- "test:record": "rimraf --glob \"**/__recordings__\" && cross-env TEST_MODE=record vitest run --exclude e2e",
42
- "test:watch": "vitest --exclude e2e",
43
- "typecheck": "tsc --noEmit"
44
- },
45
32
  "repository": {
46
33
  "type": "git",
47
34
  "url": "git+https://github.com/resend/resend-node.git"
@@ -83,5 +70,16 @@
83
70
  "vitest": "4.1.3",
84
71
  "vitest-fetch-mock": "0.4.5"
85
72
  },
86
- "packageManager": "pnpm@10.33.0"
87
- }
73
+ "scripts": {
74
+ "build": "tsdown src/index.ts --format esm,cjs --dts",
75
+ "integration:nextjs": "cd ./e2e/nextjs && next build --turbopack",
76
+ "lint": "biome check .",
77
+ "lint:fix": "biome check . --write",
78
+ "test": "vitest run --exclude e2e",
79
+ "test:dev": "cross-env TEST_MODE=dev vitest run --exclude e2e",
80
+ "test:e2e": "vitest run e2e",
81
+ "test:record": "rimraf --glob \"**/__recordings__\" && cross-env TEST_MODE=record vitest run --exclude e2e",
82
+ "test:watch": "vitest --exclude e2e",
83
+ "typecheck": "tsc --noEmit"
84
+ }
85
+ }