resend 6.10.0-preview-workflows.4 → 6.10.0-preview-workflows.7
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 +49 -35
- package/dist/index.d.cts +77 -65
- package/dist/index.d.mts +77 -65
- package/dist/index.mjs +49 -35
- package/package.json +17 -19
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.
|
|
28
|
+
var version = "6.10.0-preview-workflows.7";
|
|
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
|
|
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,61 @@ var AutomationRuns = class {
|
|
|
94
84
|
function parseStepConfig(step) {
|
|
95
85
|
switch (step.type) {
|
|
96
86
|
case "trigger": return {
|
|
97
|
-
|
|
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
|
-
|
|
92
|
+
key: step.key,
|
|
103
93
|
type: step.type,
|
|
104
94
|
config: step.config
|
|
105
95
|
};
|
|
106
96
|
case "send_email": return {
|
|
107
|
-
|
|
97
|
+
key: step.key,
|
|
108
98
|
type: step.type,
|
|
109
99
|
config: {
|
|
110
|
-
|
|
100
|
+
template: step.config.template,
|
|
111
101
|
subject: step.config.subject,
|
|
112
102
|
from: step.config.from,
|
|
113
|
-
reply_to: step.config.replyTo
|
|
114
|
-
variables: step.config.variables
|
|
103
|
+
reply_to: step.config.replyTo
|
|
115
104
|
}
|
|
116
105
|
};
|
|
117
106
|
case "wait_for_event": return {
|
|
118
|
-
|
|
107
|
+
key: step.key,
|
|
119
108
|
type: step.type,
|
|
120
109
|
config: {
|
|
121
110
|
event_name: step.config.eventName,
|
|
122
|
-
|
|
111
|
+
timeout: step.config.timeout,
|
|
123
112
|
filter_rule: step.config.filterRule
|
|
124
113
|
}
|
|
125
114
|
};
|
|
126
115
|
case "condition": return {
|
|
127
|
-
|
|
116
|
+
key: step.key,
|
|
117
|
+
type: step.type,
|
|
118
|
+
config: step.config
|
|
119
|
+
};
|
|
120
|
+
case "contact_update": return {
|
|
121
|
+
key: step.key,
|
|
122
|
+
type: step.type,
|
|
123
|
+
config: step.config
|
|
124
|
+
};
|
|
125
|
+
case "contact_delete": return {
|
|
126
|
+
key: step.key,
|
|
127
|
+
type: step.type,
|
|
128
|
+
config: step.config
|
|
129
|
+
};
|
|
130
|
+
case "add_to_segment": return {
|
|
131
|
+
key: step.key,
|
|
128
132
|
type: step.type,
|
|
129
133
|
config: step.config
|
|
130
134
|
};
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
|
-
function
|
|
137
|
+
function parseConnection(connection) {
|
|
134
138
|
return {
|
|
135
|
-
from:
|
|
136
|
-
to:
|
|
137
|
-
|
|
139
|
+
from: connection.from,
|
|
140
|
+
to: connection.to,
|
|
141
|
+
type: connection.type
|
|
138
142
|
};
|
|
139
143
|
}
|
|
140
144
|
function parseAutomationToApiOptions(automation) {
|
|
@@ -142,7 +146,7 @@ function parseAutomationToApiOptions(automation) {
|
|
|
142
146
|
name: automation.name,
|
|
143
147
|
status: automation.status,
|
|
144
148
|
steps: automation.steps.map(parseStepConfig),
|
|
145
|
-
|
|
149
|
+
connections: automation.connections.map(parseConnection)
|
|
146
150
|
};
|
|
147
151
|
}
|
|
148
152
|
function parseEventToApiOptions(event) {
|
|
@@ -164,8 +168,10 @@ var Automations = class {
|
|
|
164
168
|
return await this.resend.post("/automations", parseAutomationToApiOptions(payload));
|
|
165
169
|
}
|
|
166
170
|
async list(options = {}) {
|
|
167
|
-
const
|
|
168
|
-
|
|
171
|
+
const params = [buildPaginationQuery(options)];
|
|
172
|
+
if (options.status) params.push(`status=${encodeURIComponent(options.status)}`);
|
|
173
|
+
const qs = params.filter(Boolean).join("&");
|
|
174
|
+
const url = qs ? `/automations?${qs}` : "/automations";
|
|
169
175
|
return await this.resend.get(url);
|
|
170
176
|
}
|
|
171
177
|
async get(id) {
|
|
@@ -175,7 +181,15 @@ var Automations = class {
|
|
|
175
181
|
return await this.resend.delete(`/automations/${id}`);
|
|
176
182
|
}
|
|
177
183
|
async update(id, payload) {
|
|
178
|
-
|
|
184
|
+
const apiPayload = {};
|
|
185
|
+
if (payload.name !== void 0) apiPayload.name = payload.name;
|
|
186
|
+
if (payload.status !== void 0) apiPayload.status = payload.status;
|
|
187
|
+
if (payload.steps !== void 0) apiPayload.steps = payload.steps.map(parseStepConfig);
|
|
188
|
+
if (payload.connections !== void 0) apiPayload.connections = payload.connections.map(parseConnection);
|
|
189
|
+
return await this.resend.patch(`/automations/${id}`, apiPayload);
|
|
190
|
+
}
|
|
191
|
+
async stop(id) {
|
|
192
|
+
return await this.resend.post(`/automations/${id}/stop`);
|
|
179
193
|
}
|
|
180
194
|
};
|
|
181
195
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -269,109 +269,115 @@ interface TriggerStepConfig {
|
|
|
269
269
|
eventName: string;
|
|
270
270
|
}
|
|
271
271
|
interface DelayStepConfig {
|
|
272
|
-
|
|
272
|
+
duration: string;
|
|
273
273
|
}
|
|
274
274
|
interface SendEmailStepConfig {
|
|
275
|
-
|
|
275
|
+
template: {
|
|
276
|
+
id: string;
|
|
277
|
+
variables?: Record<string, TemplateVariableValue>;
|
|
278
|
+
};
|
|
276
279
|
subject?: string;
|
|
277
280
|
from?: string;
|
|
278
281
|
replyTo?: string;
|
|
279
|
-
variables?: Record<string, TemplateVariableValue>;
|
|
280
282
|
}
|
|
281
283
|
interface WaitForEventStepConfig {
|
|
282
284
|
eventName: string;
|
|
283
|
-
|
|
285
|
+
timeout?: string;
|
|
284
286
|
filterRule?: ConditionRule;
|
|
285
287
|
}
|
|
286
288
|
type ConditionStepConfig = ConditionRule;
|
|
289
|
+
interface ContactUpdateStepConfig {
|
|
290
|
+
first_name?: string | null | {
|
|
291
|
+
var: string;
|
|
292
|
+
};
|
|
293
|
+
last_name?: string | null | {
|
|
294
|
+
var: string;
|
|
295
|
+
};
|
|
296
|
+
unsubscribed?: boolean | {
|
|
297
|
+
var: string;
|
|
298
|
+
};
|
|
299
|
+
properties?: Record<string, string | number | boolean | null | {
|
|
300
|
+
var: string;
|
|
301
|
+
}>;
|
|
302
|
+
}
|
|
303
|
+
type ContactDeleteStepConfig = Record<string, never>;
|
|
304
|
+
interface AddToSegmentStepConfig {
|
|
305
|
+
segment_id: string;
|
|
306
|
+
}
|
|
287
307
|
type AutomationStep = {
|
|
288
|
-
|
|
308
|
+
key: string;
|
|
289
309
|
type: 'trigger';
|
|
290
310
|
config: TriggerStepConfig;
|
|
291
311
|
} | {
|
|
292
|
-
|
|
312
|
+
key: string;
|
|
293
313
|
type: 'delay';
|
|
294
314
|
config: DelayStepConfig;
|
|
295
315
|
} | {
|
|
296
|
-
|
|
316
|
+
key: string;
|
|
297
317
|
type: 'send_email';
|
|
298
318
|
config: SendEmailStepConfig;
|
|
299
319
|
} | {
|
|
300
|
-
|
|
320
|
+
key: string;
|
|
301
321
|
type: 'wait_for_event';
|
|
302
322
|
config: WaitForEventStepConfig;
|
|
303
323
|
} | {
|
|
304
|
-
|
|
324
|
+
key: string;
|
|
305
325
|
type: 'condition';
|
|
306
326
|
config: ConditionStepConfig;
|
|
327
|
+
} | {
|
|
328
|
+
key: string;
|
|
329
|
+
type: 'contact_update';
|
|
330
|
+
config: ContactUpdateStepConfig;
|
|
331
|
+
} | {
|
|
332
|
+
key: string;
|
|
333
|
+
type: 'contact_delete';
|
|
334
|
+
config: ContactDeleteStepConfig;
|
|
335
|
+
} | {
|
|
336
|
+
key: string;
|
|
337
|
+
type: 'add_to_segment';
|
|
338
|
+
config: AddToSegmentStepConfig;
|
|
307
339
|
};
|
|
308
|
-
type
|
|
309
|
-
interface
|
|
340
|
+
type AutomationConnectionType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
|
|
341
|
+
interface AutomationConnection {
|
|
310
342
|
from: string;
|
|
311
343
|
to: string;
|
|
312
|
-
|
|
344
|
+
type?: AutomationConnectionType;
|
|
313
345
|
}
|
|
314
346
|
type AutomationStepType = AutomationStep['type'];
|
|
315
347
|
interface AutomationResponseStep {
|
|
316
|
-
|
|
348
|
+
key: string;
|
|
317
349
|
type: AutomationStepType;
|
|
318
350
|
config: Record<string, unknown>;
|
|
319
351
|
}
|
|
320
|
-
interface
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
edge_type: AutomationEdgeType;
|
|
352
|
+
interface AutomationResponseConnection {
|
|
353
|
+
from: string;
|
|
354
|
+
to: string;
|
|
355
|
+
type: AutomationConnectionType;
|
|
325
356
|
}
|
|
326
357
|
//#endregion
|
|
327
|
-
//#region src/automation-
|
|
358
|
+
//#region src/automation-runs/interfaces/automation-run.d.ts
|
|
359
|
+
type AutomationRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
|
|
328
360
|
type AutomationRunStepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped' | 'waiting';
|
|
329
361
|
interface AutomationRunStep {
|
|
330
|
-
|
|
331
|
-
id: string;
|
|
332
|
-
step_id: string;
|
|
362
|
+
key: string;
|
|
333
363
|
type: AutomationStepType;
|
|
334
|
-
config: Record<string, unknown>;
|
|
335
364
|
status: AutomationRunStepStatus;
|
|
365
|
+
output: Record<string, unknown> | null;
|
|
366
|
+
error: Record<string, unknown> | null;
|
|
336
367
|
started_at: string | null;
|
|
337
368
|
completed_at: string | null;
|
|
338
369
|
created_at: string;
|
|
339
370
|
}
|
|
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
371
|
interface AutomationRun {
|
|
366
372
|
object: 'automation_run';
|
|
367
373
|
id: string;
|
|
368
374
|
status: AutomationRunStatus;
|
|
369
|
-
trigger: AutomationRunTrigger | null;
|
|
370
375
|
started_at: string | null;
|
|
371
376
|
completed_at: string | null;
|
|
372
377
|
created_at: string;
|
|
378
|
+
steps: AutomationRunStep[];
|
|
373
379
|
}
|
|
374
|
-
type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | '
|
|
380
|
+
type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
|
|
375
381
|
//#endregion
|
|
376
382
|
//#region src/automation-runs/interfaces/get-automation-run.interface.d.ts
|
|
377
383
|
interface GetAutomationRunOptions {
|
|
@@ -384,6 +390,7 @@ type GetAutomationRunResponse = Response<GetAutomationRunResponseSuccess>;
|
|
|
384
390
|
//#region src/automation-runs/interfaces/list-automation-runs.interface.d.ts
|
|
385
391
|
type ListAutomationRunsOptions = PaginationOptions & {
|
|
386
392
|
automationId: string;
|
|
393
|
+
status?: AutomationRunStatus | AutomationRunStatus[];
|
|
387
394
|
};
|
|
388
395
|
type ListAutomationRunsResponseSuccess = PaginatedData<AutomationRunItem[]>;
|
|
389
396
|
type ListAutomationRunsResponse = Response<ListAutomationRunsResponseSuccess>;
|
|
@@ -403,7 +410,7 @@ interface CreateAutomationOptions {
|
|
|
403
410
|
name: string;
|
|
404
411
|
status?: AutomationStatus;
|
|
405
412
|
steps: AutomationStep[];
|
|
406
|
-
|
|
413
|
+
connections: AutomationConnection[];
|
|
407
414
|
}
|
|
408
415
|
interface CreateAutomationResponseSuccess {
|
|
409
416
|
object: 'automation';
|
|
@@ -415,12 +422,14 @@ type CreateAutomationResponse = Response<CreateAutomationResponseSuccess>;
|
|
|
415
422
|
interface GetAutomationResponseSuccess extends Automation {
|
|
416
423
|
object: 'automation';
|
|
417
424
|
steps: AutomationResponseStep[];
|
|
418
|
-
|
|
425
|
+
connections: AutomationResponseConnection[];
|
|
419
426
|
}
|
|
420
427
|
type GetAutomationResponse = Response<GetAutomationResponseSuccess>;
|
|
421
428
|
//#endregion
|
|
422
429
|
//#region src/automations/interfaces/list-automation.interface.d.ts
|
|
423
|
-
type ListAutomationsOptions = PaginationOptions
|
|
430
|
+
type ListAutomationsOptions = PaginationOptions & {
|
|
431
|
+
status?: AutomationStatus;
|
|
432
|
+
};
|
|
424
433
|
type ListAutomationsResponseSuccess = PaginatedData<Automation[]>;
|
|
425
434
|
type ListAutomationsResponse = Response<ListAutomationsResponseSuccess>;
|
|
426
435
|
//#endregion
|
|
@@ -431,11 +440,22 @@ interface RemoveAutomationResponseSuccess extends Pick<Automation, 'id'> {
|
|
|
431
440
|
}
|
|
432
441
|
type RemoveAutomationResponse = Response<RemoveAutomationResponseSuccess>;
|
|
433
442
|
//#endregion
|
|
443
|
+
//#region src/automations/interfaces/stop-automation.interface.d.ts
|
|
444
|
+
interface StopAutomationResponseSuccess {
|
|
445
|
+
object: 'automation';
|
|
446
|
+
id: string;
|
|
447
|
+
status: 'disabled';
|
|
448
|
+
}
|
|
449
|
+
type StopAutomationResponse = Response<StopAutomationResponseSuccess>;
|
|
450
|
+
//#endregion
|
|
434
451
|
//#region src/automations/interfaces/update-automation.interface.d.ts
|
|
435
452
|
interface UpdateAutomationOptions {
|
|
436
|
-
|
|
453
|
+
name?: string;
|
|
454
|
+
status?: AutomationStatus;
|
|
455
|
+
steps?: AutomationStep[];
|
|
456
|
+
connections?: AutomationConnection[];
|
|
437
457
|
}
|
|
438
|
-
interface UpdateAutomationResponseSuccess extends Pick<Automation, 'id'
|
|
458
|
+
interface UpdateAutomationResponseSuccess extends Pick<Automation, 'id'> {
|
|
439
459
|
object: 'automation';
|
|
440
460
|
}
|
|
441
461
|
type UpdateAutomationResponse = Response<UpdateAutomationResponseSuccess>;
|
|
@@ -1429,18 +1449,9 @@ declare class ApiKeys {
|
|
|
1429
1449
|
remove(id: string): Promise<RemoveApiKeyResponse>;
|
|
1430
1450
|
}
|
|
1431
1451
|
//#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
1452
|
//#region src/automation-runs/automation-runs.d.ts
|
|
1441
1453
|
declare class AutomationRuns {
|
|
1442
1454
|
private readonly resend;
|
|
1443
|
-
readonly steps: AutomationRunSteps;
|
|
1444
1455
|
constructor(resend: Resend);
|
|
1445
1456
|
get(options: GetAutomationRunOptions): Promise<GetAutomationRunResponse>;
|
|
1446
1457
|
list(options: ListAutomationRunsOptions): Promise<ListAutomationRunsResponse>;
|
|
@@ -1456,6 +1467,7 @@ declare class Automations {
|
|
|
1456
1467
|
get(id: string): Promise<GetAutomationResponse>;
|
|
1457
1468
|
remove(id: string): Promise<RemoveAutomationResponse>;
|
|
1458
1469
|
update(id: string, payload: UpdateAutomationOptions): Promise<UpdateAutomationResponse>;
|
|
1470
|
+
stop(id: string): Promise<StopAutomationResponse>;
|
|
1459
1471
|
}
|
|
1460
1472
|
//#endregion
|
|
1461
1473
|
//#region src/batch/batch.d.ts
|
|
@@ -2104,4 +2116,4 @@ declare class Resend {
|
|
|
2104
2116
|
delete<T>(path: string, query?: unknown): Promise<Response<T>>;
|
|
2105
2117
|
}
|
|
2106
2118
|
//#endregion
|
|
2107
|
-
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation,
|
|
2119
|
+
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,109 +269,115 @@ interface TriggerStepConfig {
|
|
|
269
269
|
eventName: string;
|
|
270
270
|
}
|
|
271
271
|
interface DelayStepConfig {
|
|
272
|
-
|
|
272
|
+
duration: string;
|
|
273
273
|
}
|
|
274
274
|
interface SendEmailStepConfig {
|
|
275
|
-
|
|
275
|
+
template: {
|
|
276
|
+
id: string;
|
|
277
|
+
variables?: Record<string, TemplateVariableValue>;
|
|
278
|
+
};
|
|
276
279
|
subject?: string;
|
|
277
280
|
from?: string;
|
|
278
281
|
replyTo?: string;
|
|
279
|
-
variables?: Record<string, TemplateVariableValue>;
|
|
280
282
|
}
|
|
281
283
|
interface WaitForEventStepConfig {
|
|
282
284
|
eventName: string;
|
|
283
|
-
|
|
285
|
+
timeout?: string;
|
|
284
286
|
filterRule?: ConditionRule;
|
|
285
287
|
}
|
|
286
288
|
type ConditionStepConfig = ConditionRule;
|
|
289
|
+
interface ContactUpdateStepConfig {
|
|
290
|
+
first_name?: string | null | {
|
|
291
|
+
var: string;
|
|
292
|
+
};
|
|
293
|
+
last_name?: string | null | {
|
|
294
|
+
var: string;
|
|
295
|
+
};
|
|
296
|
+
unsubscribed?: boolean | {
|
|
297
|
+
var: string;
|
|
298
|
+
};
|
|
299
|
+
properties?: Record<string, string | number | boolean | null | {
|
|
300
|
+
var: string;
|
|
301
|
+
}>;
|
|
302
|
+
}
|
|
303
|
+
type ContactDeleteStepConfig = Record<string, never>;
|
|
304
|
+
interface AddToSegmentStepConfig {
|
|
305
|
+
segment_id: string;
|
|
306
|
+
}
|
|
287
307
|
type AutomationStep = {
|
|
288
|
-
|
|
308
|
+
key: string;
|
|
289
309
|
type: 'trigger';
|
|
290
310
|
config: TriggerStepConfig;
|
|
291
311
|
} | {
|
|
292
|
-
|
|
312
|
+
key: string;
|
|
293
313
|
type: 'delay';
|
|
294
314
|
config: DelayStepConfig;
|
|
295
315
|
} | {
|
|
296
|
-
|
|
316
|
+
key: string;
|
|
297
317
|
type: 'send_email';
|
|
298
318
|
config: SendEmailStepConfig;
|
|
299
319
|
} | {
|
|
300
|
-
|
|
320
|
+
key: string;
|
|
301
321
|
type: 'wait_for_event';
|
|
302
322
|
config: WaitForEventStepConfig;
|
|
303
323
|
} | {
|
|
304
|
-
|
|
324
|
+
key: string;
|
|
305
325
|
type: 'condition';
|
|
306
326
|
config: ConditionStepConfig;
|
|
327
|
+
} | {
|
|
328
|
+
key: string;
|
|
329
|
+
type: 'contact_update';
|
|
330
|
+
config: ContactUpdateStepConfig;
|
|
331
|
+
} | {
|
|
332
|
+
key: string;
|
|
333
|
+
type: 'contact_delete';
|
|
334
|
+
config: ContactDeleteStepConfig;
|
|
335
|
+
} | {
|
|
336
|
+
key: string;
|
|
337
|
+
type: 'add_to_segment';
|
|
338
|
+
config: AddToSegmentStepConfig;
|
|
307
339
|
};
|
|
308
|
-
type
|
|
309
|
-
interface
|
|
340
|
+
type AutomationConnectionType = 'default' | 'condition_met' | 'condition_not_met' | 'timeout' | 'event_received';
|
|
341
|
+
interface AutomationConnection {
|
|
310
342
|
from: string;
|
|
311
343
|
to: string;
|
|
312
|
-
|
|
344
|
+
type?: AutomationConnectionType;
|
|
313
345
|
}
|
|
314
346
|
type AutomationStepType = AutomationStep['type'];
|
|
315
347
|
interface AutomationResponseStep {
|
|
316
|
-
|
|
348
|
+
key: string;
|
|
317
349
|
type: AutomationStepType;
|
|
318
350
|
config: Record<string, unknown>;
|
|
319
351
|
}
|
|
320
|
-
interface
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
edge_type: AutomationEdgeType;
|
|
352
|
+
interface AutomationResponseConnection {
|
|
353
|
+
from: string;
|
|
354
|
+
to: string;
|
|
355
|
+
type: AutomationConnectionType;
|
|
325
356
|
}
|
|
326
357
|
//#endregion
|
|
327
|
-
//#region src/automation-
|
|
358
|
+
//#region src/automation-runs/interfaces/automation-run.d.ts
|
|
359
|
+
type AutomationRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
|
|
328
360
|
type AutomationRunStepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped' | 'waiting';
|
|
329
361
|
interface AutomationRunStep {
|
|
330
|
-
|
|
331
|
-
id: string;
|
|
332
|
-
step_id: string;
|
|
362
|
+
key: string;
|
|
333
363
|
type: AutomationStepType;
|
|
334
|
-
config: Record<string, unknown>;
|
|
335
364
|
status: AutomationRunStepStatus;
|
|
365
|
+
output: Record<string, unknown> | null;
|
|
366
|
+
error: Record<string, unknown> | null;
|
|
336
367
|
started_at: string | null;
|
|
337
368
|
completed_at: string | null;
|
|
338
369
|
created_at: string;
|
|
339
370
|
}
|
|
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
371
|
interface AutomationRun {
|
|
366
372
|
object: 'automation_run';
|
|
367
373
|
id: string;
|
|
368
374
|
status: AutomationRunStatus;
|
|
369
|
-
trigger: AutomationRunTrigger | null;
|
|
370
375
|
started_at: string | null;
|
|
371
376
|
completed_at: string | null;
|
|
372
377
|
created_at: string;
|
|
378
|
+
steps: AutomationRunStep[];
|
|
373
379
|
}
|
|
374
|
-
type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | '
|
|
380
|
+
type AutomationRunItem = Pick<AutomationRun, 'id' | 'status' | 'started_at' | 'completed_at' | 'created_at'>;
|
|
375
381
|
//#endregion
|
|
376
382
|
//#region src/automation-runs/interfaces/get-automation-run.interface.d.ts
|
|
377
383
|
interface GetAutomationRunOptions {
|
|
@@ -384,6 +390,7 @@ type GetAutomationRunResponse = Response<GetAutomationRunResponseSuccess>;
|
|
|
384
390
|
//#region src/automation-runs/interfaces/list-automation-runs.interface.d.ts
|
|
385
391
|
type ListAutomationRunsOptions = PaginationOptions & {
|
|
386
392
|
automationId: string;
|
|
393
|
+
status?: AutomationRunStatus | AutomationRunStatus[];
|
|
387
394
|
};
|
|
388
395
|
type ListAutomationRunsResponseSuccess = PaginatedData<AutomationRunItem[]>;
|
|
389
396
|
type ListAutomationRunsResponse = Response<ListAutomationRunsResponseSuccess>;
|
|
@@ -403,7 +410,7 @@ interface CreateAutomationOptions {
|
|
|
403
410
|
name: string;
|
|
404
411
|
status?: AutomationStatus;
|
|
405
412
|
steps: AutomationStep[];
|
|
406
|
-
|
|
413
|
+
connections: AutomationConnection[];
|
|
407
414
|
}
|
|
408
415
|
interface CreateAutomationResponseSuccess {
|
|
409
416
|
object: 'automation';
|
|
@@ -415,12 +422,14 @@ type CreateAutomationResponse = Response<CreateAutomationResponseSuccess>;
|
|
|
415
422
|
interface GetAutomationResponseSuccess extends Automation {
|
|
416
423
|
object: 'automation';
|
|
417
424
|
steps: AutomationResponseStep[];
|
|
418
|
-
|
|
425
|
+
connections: AutomationResponseConnection[];
|
|
419
426
|
}
|
|
420
427
|
type GetAutomationResponse = Response<GetAutomationResponseSuccess>;
|
|
421
428
|
//#endregion
|
|
422
429
|
//#region src/automations/interfaces/list-automation.interface.d.ts
|
|
423
|
-
type ListAutomationsOptions = PaginationOptions
|
|
430
|
+
type ListAutomationsOptions = PaginationOptions & {
|
|
431
|
+
status?: AutomationStatus;
|
|
432
|
+
};
|
|
424
433
|
type ListAutomationsResponseSuccess = PaginatedData<Automation[]>;
|
|
425
434
|
type ListAutomationsResponse = Response<ListAutomationsResponseSuccess>;
|
|
426
435
|
//#endregion
|
|
@@ -431,11 +440,22 @@ interface RemoveAutomationResponseSuccess extends Pick<Automation, 'id'> {
|
|
|
431
440
|
}
|
|
432
441
|
type RemoveAutomationResponse = Response<RemoveAutomationResponseSuccess>;
|
|
433
442
|
//#endregion
|
|
443
|
+
//#region src/automations/interfaces/stop-automation.interface.d.ts
|
|
444
|
+
interface StopAutomationResponseSuccess {
|
|
445
|
+
object: 'automation';
|
|
446
|
+
id: string;
|
|
447
|
+
status: 'disabled';
|
|
448
|
+
}
|
|
449
|
+
type StopAutomationResponse = Response<StopAutomationResponseSuccess>;
|
|
450
|
+
//#endregion
|
|
434
451
|
//#region src/automations/interfaces/update-automation.interface.d.ts
|
|
435
452
|
interface UpdateAutomationOptions {
|
|
436
|
-
|
|
453
|
+
name?: string;
|
|
454
|
+
status?: AutomationStatus;
|
|
455
|
+
steps?: AutomationStep[];
|
|
456
|
+
connections?: AutomationConnection[];
|
|
437
457
|
}
|
|
438
|
-
interface UpdateAutomationResponseSuccess extends Pick<Automation, 'id'
|
|
458
|
+
interface UpdateAutomationResponseSuccess extends Pick<Automation, 'id'> {
|
|
439
459
|
object: 'automation';
|
|
440
460
|
}
|
|
441
461
|
type UpdateAutomationResponse = Response<UpdateAutomationResponseSuccess>;
|
|
@@ -1429,18 +1449,9 @@ declare class ApiKeys {
|
|
|
1429
1449
|
remove(id: string): Promise<RemoveApiKeyResponse>;
|
|
1430
1450
|
}
|
|
1431
1451
|
//#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
1452
|
//#region src/automation-runs/automation-runs.d.ts
|
|
1441
1453
|
declare class AutomationRuns {
|
|
1442
1454
|
private readonly resend;
|
|
1443
|
-
readonly steps: AutomationRunSteps;
|
|
1444
1455
|
constructor(resend: Resend);
|
|
1445
1456
|
get(options: GetAutomationRunOptions): Promise<GetAutomationRunResponse>;
|
|
1446
1457
|
list(options: ListAutomationRunsOptions): Promise<ListAutomationRunsResponse>;
|
|
@@ -1456,6 +1467,7 @@ declare class Automations {
|
|
|
1456
1467
|
get(id: string): Promise<GetAutomationResponse>;
|
|
1457
1468
|
remove(id: string): Promise<RemoveAutomationResponse>;
|
|
1458
1469
|
update(id: string, payload: UpdateAutomationOptions): Promise<UpdateAutomationResponse>;
|
|
1470
|
+
stop(id: string): Promise<StopAutomationResponse>;
|
|
1459
1471
|
}
|
|
1460
1472
|
//#endregion
|
|
1461
1473
|
//#region src/batch/batch.d.ts
|
|
@@ -2104,4 +2116,4 @@ declare class Resend {
|
|
|
2104
2116
|
delete<T>(path: string, query?: unknown): Promise<Response<T>>;
|
|
2105
2117
|
}
|
|
2106
2118
|
//#endregion
|
|
2107
|
-
export { AddContactSegmentOptions, AddContactSegmentResponse, AddContactSegmentResponseSuccess, ApiContactProperty, ApiKey, Attachment, AttachmentData, Automation,
|
|
2119
|
+
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
|
+
var version = "6.10.0-preview-workflows.7";
|
|
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
|
|
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,61 @@ var AutomationRuns = class {
|
|
|
70
60
|
function parseStepConfig(step) {
|
|
71
61
|
switch (step.type) {
|
|
72
62
|
case "trigger": return {
|
|
73
|
-
|
|
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
|
-
|
|
68
|
+
key: step.key,
|
|
79
69
|
type: step.type,
|
|
80
70
|
config: step.config
|
|
81
71
|
};
|
|
82
72
|
case "send_email": return {
|
|
83
|
-
|
|
73
|
+
key: step.key,
|
|
84
74
|
type: step.type,
|
|
85
75
|
config: {
|
|
86
|
-
|
|
76
|
+
template: step.config.template,
|
|
87
77
|
subject: step.config.subject,
|
|
88
78
|
from: step.config.from,
|
|
89
|
-
reply_to: step.config.replyTo
|
|
90
|
-
variables: step.config.variables
|
|
79
|
+
reply_to: step.config.replyTo
|
|
91
80
|
}
|
|
92
81
|
};
|
|
93
82
|
case "wait_for_event": return {
|
|
94
|
-
|
|
83
|
+
key: step.key,
|
|
95
84
|
type: step.type,
|
|
96
85
|
config: {
|
|
97
86
|
event_name: step.config.eventName,
|
|
98
|
-
|
|
87
|
+
timeout: step.config.timeout,
|
|
99
88
|
filter_rule: step.config.filterRule
|
|
100
89
|
}
|
|
101
90
|
};
|
|
102
91
|
case "condition": return {
|
|
103
|
-
|
|
92
|
+
key: step.key,
|
|
93
|
+
type: step.type,
|
|
94
|
+
config: step.config
|
|
95
|
+
};
|
|
96
|
+
case "contact_update": return {
|
|
97
|
+
key: step.key,
|
|
98
|
+
type: step.type,
|
|
99
|
+
config: step.config
|
|
100
|
+
};
|
|
101
|
+
case "contact_delete": return {
|
|
102
|
+
key: step.key,
|
|
103
|
+
type: step.type,
|
|
104
|
+
config: step.config
|
|
105
|
+
};
|
|
106
|
+
case "add_to_segment": return {
|
|
107
|
+
key: step.key,
|
|
104
108
|
type: step.type,
|
|
105
109
|
config: step.config
|
|
106
110
|
};
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
|
-
function
|
|
113
|
+
function parseConnection(connection) {
|
|
110
114
|
return {
|
|
111
|
-
from:
|
|
112
|
-
to:
|
|
113
|
-
|
|
115
|
+
from: connection.from,
|
|
116
|
+
to: connection.to,
|
|
117
|
+
type: connection.type
|
|
114
118
|
};
|
|
115
119
|
}
|
|
116
120
|
function parseAutomationToApiOptions(automation) {
|
|
@@ -118,7 +122,7 @@ function parseAutomationToApiOptions(automation) {
|
|
|
118
122
|
name: automation.name,
|
|
119
123
|
status: automation.status,
|
|
120
124
|
steps: automation.steps.map(parseStepConfig),
|
|
121
|
-
|
|
125
|
+
connections: automation.connections.map(parseConnection)
|
|
122
126
|
};
|
|
123
127
|
}
|
|
124
128
|
function parseEventToApiOptions(event) {
|
|
@@ -140,8 +144,10 @@ var Automations = class {
|
|
|
140
144
|
return await this.resend.post("/automations", parseAutomationToApiOptions(payload));
|
|
141
145
|
}
|
|
142
146
|
async list(options = {}) {
|
|
143
|
-
const
|
|
144
|
-
|
|
147
|
+
const params = [buildPaginationQuery(options)];
|
|
148
|
+
if (options.status) params.push(`status=${encodeURIComponent(options.status)}`);
|
|
149
|
+
const qs = params.filter(Boolean).join("&");
|
|
150
|
+
const url = qs ? `/automations?${qs}` : "/automations";
|
|
145
151
|
return await this.resend.get(url);
|
|
146
152
|
}
|
|
147
153
|
async get(id) {
|
|
@@ -151,7 +157,15 @@ var Automations = class {
|
|
|
151
157
|
return await this.resend.delete(`/automations/${id}`);
|
|
152
158
|
}
|
|
153
159
|
async update(id, payload) {
|
|
154
|
-
|
|
160
|
+
const apiPayload = {};
|
|
161
|
+
if (payload.name !== void 0) apiPayload.name = payload.name;
|
|
162
|
+
if (payload.status !== void 0) apiPayload.status = payload.status;
|
|
163
|
+
if (payload.steps !== void 0) apiPayload.steps = payload.steps.map(parseStepConfig);
|
|
164
|
+
if (payload.connections !== void 0) apiPayload.connections = payload.connections.map(parseConnection);
|
|
165
|
+
return await this.resend.patch(`/automations/${id}`, apiPayload);
|
|
166
|
+
}
|
|
167
|
+
async stop(id) {
|
|
168
|
+
return await this.resend.post(`/automations/${id}/stop`);
|
|
155
169
|
}
|
|
156
170
|
};
|
|
157
171
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "6.10.0-preview-workflows.
|
|
3
|
+
"version": "6.10.0-preview-workflows.7",
|
|
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"
|
|
@@ -75,13 +62,24 @@
|
|
|
75
62
|
"cross-env": "10.1.0",
|
|
76
63
|
"dotenv": "17.4.1",
|
|
77
64
|
"pkg-pr-new": "0.0.66",
|
|
78
|
-
"react": "19.2.
|
|
79
|
-
"react-dom": "19.2.
|
|
65
|
+
"react": "19.2.5",
|
|
66
|
+
"react-dom": "19.2.5",
|
|
80
67
|
"rimraf": "6.1.3",
|
|
81
68
|
"tsdown": "0.21.4",
|
|
82
69
|
"typescript": "6.0.2",
|
|
83
|
-
"vitest": "4.1.
|
|
70
|
+
"vitest": "4.1.4",
|
|
84
71
|
"vitest-fetch-mock": "0.4.5"
|
|
85
72
|
},
|
|
86
|
-
"
|
|
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
|
+
}
|