@keystrokehq/resend 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +184 -0
- package/dist/_official/index.d.mts +2 -0
- package/dist/_official/index.mjs +3 -0
- package/dist/_runtime/index.d.mts +1 -0
- package/dist/_runtime/index.mjs +1 -0
- package/dist/api-keys.d.mts +67 -0
- package/dist/api-keys.mjs +90 -0
- package/dist/broadcasts.d.mts +238 -0
- package/dist/broadcasts.mjs +178 -0
- package/dist/client.d.mts +27 -0
- package/dist/client.mjs +40 -0
- package/dist/connection.d.mts +2 -0
- package/dist/connection.mjs +3 -0
- package/dist/contact-properties.d.mts +139 -0
- package/dist/contact-properties.mjs +115 -0
- package/dist/contacts.d.mts +218 -0
- package/dist/contacts.mjs +225 -0
- package/dist/domains.d.mts +293 -0
- package/dist/domains.mjs +160 -0
- package/dist/emails-receiving.d.mts +177 -0
- package/dist/emails-receiving.mjs +114 -0
- package/dist/emails.d.mts +307 -0
- package/dist/emails.mjs +241 -0
- package/dist/events.d.mts +571 -0
- package/dist/events.mjs +178 -0
- package/dist/factory-B3VyPRsL.mjs +8 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -0
- package/dist/integration-BR1nTAnU.mjs +28 -0
- package/dist/integration-ClH0F7x-.d.mts +49 -0
- package/dist/logs.d.mts +71 -0
- package/dist/logs.mjs +61 -0
- package/dist/schemas.d.mts +77 -0
- package/dist/schemas.mjs +68 -0
- package/dist/segments.d.mts +112 -0
- package/dist/segments.mjs +120 -0
- package/dist/templates.d.mts +193 -0
- package/dist/templates.mjs +151 -0
- package/dist/topics.d.mts +125 -0
- package/dist/topics.mjs +113 -0
- package/dist/triggers.d.mts +68 -0
- package/dist/triggers.mjs +141 -0
- package/dist/verification.d.mts +49 -0
- package/dist/verification.mjs +139 -0
- package/dist/webhooks.d.mts +285 -0
- package/dist/webhooks.mjs +124 -0
- package/package.json +137 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import * as _keystrokehq_core_credential_set0 from "@keystrokehq/core/credential-set";
|
|
3
|
+
import * as _keystrokehq_core0 from "@keystrokehq/core";
|
|
4
|
+
|
|
5
|
+
//#region src/contacts.d.ts
|
|
6
|
+
declare const contactSummarySchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
email: z.ZodString;
|
|
9
|
+
first_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
10
|
+
last_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
11
|
+
unsubscribed: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
13
|
+
updated_at: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$loose>;
|
|
15
|
+
declare const contactDetailSchema: z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
email: z.ZodString;
|
|
18
|
+
first_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
19
|
+
last_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
20
|
+
unsubscribed: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
22
|
+
updated_at: z.ZodOptional<z.ZodString>;
|
|
23
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
24
|
+
segment_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
}, z.core.$loose>;
|
|
26
|
+
declare const createContact: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
27
|
+
email: z.ZodEmail;
|
|
28
|
+
first_name: z.ZodOptional<z.ZodString>;
|
|
29
|
+
last_name: z.ZodOptional<z.ZodString>;
|
|
30
|
+
unsubscribed: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
32
|
+
segment_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
topic_subscriptions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
34
|
+
topic_id: z.ZodString;
|
|
35
|
+
status: z.ZodEnum<{
|
|
36
|
+
opt_in: "opt_in";
|
|
37
|
+
opt_out: "opt_out";
|
|
38
|
+
}>;
|
|
39
|
+
}, z.core.$strip>>>;
|
|
40
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
email: z.ZodString;
|
|
43
|
+
first_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
44
|
+
last_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
45
|
+
unsubscribed: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
47
|
+
updated_at: z.ZodOptional<z.ZodString>;
|
|
48
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
49
|
+
segment_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
+
}, z.core.$loose>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
51
|
+
RESEND_API_KEY: z.ZodString;
|
|
52
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
53
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
54
|
+
RESEND_API_KEY: z.ZodString;
|
|
55
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
56
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
57
|
+
declare const listContacts: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
58
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
59
|
+
after: z.ZodOptional<z.ZodString>;
|
|
60
|
+
before: z.ZodOptional<z.ZodString>;
|
|
61
|
+
segment_id: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
63
|
+
object: z.ZodLiteral<"list">;
|
|
64
|
+
has_more: z.ZodBoolean;
|
|
65
|
+
data: z.ZodArray<z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
email: z.ZodString;
|
|
68
|
+
first_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
69
|
+
last_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
70
|
+
unsubscribed: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
72
|
+
updated_at: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$loose>>;
|
|
74
|
+
}, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
75
|
+
RESEND_API_KEY: z.ZodString;
|
|
76
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
77
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
78
|
+
RESEND_API_KEY: z.ZodString;
|
|
79
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
80
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
81
|
+
declare const retrieveContact: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
84
|
+
id: z.ZodString;
|
|
85
|
+
email: z.ZodString;
|
|
86
|
+
first_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
87
|
+
last_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
88
|
+
unsubscribed: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
90
|
+
updated_at: z.ZodOptional<z.ZodString>;
|
|
91
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
92
|
+
segment_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
93
|
+
}, z.core.$loose>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
94
|
+
RESEND_API_KEY: z.ZodString;
|
|
95
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
96
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
97
|
+
RESEND_API_KEY: z.ZodString;
|
|
98
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
99
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
100
|
+
declare const updateContact: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
101
|
+
id: z.ZodString;
|
|
102
|
+
email: z.ZodOptional<z.ZodEmail>;
|
|
103
|
+
first_name: z.ZodOptional<z.ZodString>;
|
|
104
|
+
last_name: z.ZodOptional<z.ZodString>;
|
|
105
|
+
unsubscribed: z.ZodOptional<z.ZodBoolean>;
|
|
106
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
107
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
108
|
+
id: z.ZodString;
|
|
109
|
+
email: z.ZodString;
|
|
110
|
+
first_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
111
|
+
last_name: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
112
|
+
unsubscribed: z.ZodOptional<z.ZodBoolean>;
|
|
113
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
114
|
+
updated_at: z.ZodOptional<z.ZodString>;
|
|
115
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
116
|
+
segment_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
117
|
+
}, z.core.$loose>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
118
|
+
RESEND_API_KEY: z.ZodString;
|
|
119
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
120
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
121
|
+
RESEND_API_KEY: z.ZodString;
|
|
122
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
123
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
124
|
+
declare const deleteContact: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
125
|
+
id: z.ZodString;
|
|
126
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
127
|
+
object: z.ZodOptional<z.ZodLiteral<"contact">>;
|
|
128
|
+
id: z.ZodString;
|
|
129
|
+
deleted: z.ZodOptional<z.ZodBoolean>;
|
|
130
|
+
}, z.core.$loose>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
131
|
+
RESEND_API_KEY: z.ZodString;
|
|
132
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
133
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
134
|
+
RESEND_API_KEY: z.ZodString;
|
|
135
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
136
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
137
|
+
declare const addContactToSegment: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
138
|
+
contact_id: z.ZodString;
|
|
139
|
+
segment_id: z.ZodString;
|
|
140
|
+
}, z.core.$strip>, z.ZodObject<{}, z.core.$loose>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
141
|
+
RESEND_API_KEY: z.ZodString;
|
|
142
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
143
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
144
|
+
RESEND_API_KEY: z.ZodString;
|
|
145
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
146
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
147
|
+
declare const removeContactFromSegment: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
148
|
+
contact_id: z.ZodString;
|
|
149
|
+
segment_id: z.ZodString;
|
|
150
|
+
}, z.core.$strip>, z.ZodObject<{}, z.core.$loose>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
151
|
+
RESEND_API_KEY: z.ZodString;
|
|
152
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
153
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
154
|
+
RESEND_API_KEY: z.ZodString;
|
|
155
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
156
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
157
|
+
declare const listContactSegments: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
158
|
+
contact_id: z.ZodString;
|
|
159
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
160
|
+
object: z.ZodLiteral<"list">;
|
|
161
|
+
has_more: z.ZodBoolean;
|
|
162
|
+
data: z.ZodArray<z.ZodObject<{
|
|
163
|
+
id: z.ZodString;
|
|
164
|
+
name: z.ZodOptional<z.ZodString>;
|
|
165
|
+
created_at: z.ZodOptional<z.ZodString>;
|
|
166
|
+
}, z.core.$loose>>;
|
|
167
|
+
}, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
168
|
+
RESEND_API_KEY: z.ZodString;
|
|
169
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
170
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
171
|
+
RESEND_API_KEY: z.ZodString;
|
|
172
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
173
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
174
|
+
declare const getContactTopics: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
175
|
+
contact_id: z.ZodString;
|
|
176
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
177
|
+
data: z.ZodArray<z.ZodObject<{
|
|
178
|
+
topic_id: z.ZodString;
|
|
179
|
+
status: z.ZodEnum<{
|
|
180
|
+
opt_in: "opt_in";
|
|
181
|
+
opt_out: "opt_out";
|
|
182
|
+
}>;
|
|
183
|
+
}, z.core.$loose>>;
|
|
184
|
+
}, z.core.$loose>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
185
|
+
RESEND_API_KEY: z.ZodString;
|
|
186
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
187
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
188
|
+
RESEND_API_KEY: z.ZodString;
|
|
189
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
190
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
191
|
+
declare const updateContactTopics: _keystrokehq_core0.Operation<z.ZodObject<{
|
|
192
|
+
contact_id: z.ZodString;
|
|
193
|
+
subscriptions: z.ZodArray<z.ZodObject<{
|
|
194
|
+
topic_id: z.ZodString;
|
|
195
|
+
status: z.ZodEnum<{
|
|
196
|
+
opt_in: "opt_in";
|
|
197
|
+
opt_out: "opt_out";
|
|
198
|
+
}>;
|
|
199
|
+
}, z.core.$strip>>;
|
|
200
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
201
|
+
data: z.ZodArray<z.ZodObject<{
|
|
202
|
+
topic_id: z.ZodString;
|
|
203
|
+
status: z.ZodEnum<{
|
|
204
|
+
opt_in: "opt_in";
|
|
205
|
+
opt_out: "opt_out";
|
|
206
|
+
}>;
|
|
207
|
+
}, z.core.$loose>>;
|
|
208
|
+
}, z.core.$loose>, readonly [_keystrokehq_core0.CredentialSet<"resend", z.ZodObject<{
|
|
209
|
+
RESEND_API_KEY: z.ZodString;
|
|
210
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
211
|
+
}, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
|
|
212
|
+
RESEND_API_KEY: z.ZodString;
|
|
213
|
+
RESEND_WEBHOOK_SIGNING_SECRETS: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
214
|
+
}, z.core.$strip>>[] | undefined>], undefined>;
|
|
215
|
+
type ResendContactSummary = z.infer<typeof contactSummarySchema>;
|
|
216
|
+
type ResendContactDetail = z.infer<typeof contactDetailSchema>;
|
|
217
|
+
//#endregion
|
|
218
|
+
export { ResendContactDetail, ResendContactSummary, addContactToSegment, createContact, deleteContact, getContactTopics, listContactSegments, listContacts, removeContactFromSegment, retrieveContact, updateContact, updateContactTopics };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { createResendClient } from "./client.mjs";
|
|
2
|
+
import { paginationQuerySchema, resendListEnvelope } from "./schemas.mjs";
|
|
3
|
+
import { t as resendOperation } from "./factory-B3VyPRsL.mjs";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
//#region src/contacts.ts
|
|
7
|
+
/**
|
|
8
|
+
* resend/contacts.ts
|
|
9
|
+
*
|
|
10
|
+
* Operations backing the Resend `/contacts` endpoints.
|
|
11
|
+
* PLAN.md § 6.6: 10 operations.
|
|
12
|
+
*
|
|
13
|
+
* Contacts are the audience store for Broadcasts. A contact belongs to
|
|
14
|
+
* zero or more Segments and has typed properties (see
|
|
15
|
+
* `contact-properties.ts`). Topic subscriptions control which
|
|
16
|
+
* broadcasts a contact receives when `topic_id` is set on a send.
|
|
17
|
+
*/
|
|
18
|
+
const topicSubscriptionStateSchema = z.enum(["opt_in", "opt_out"]);
|
|
19
|
+
const contactPropertiesValueSchema = z.union([
|
|
20
|
+
z.string(),
|
|
21
|
+
z.number(),
|
|
22
|
+
z.boolean(),
|
|
23
|
+
z.null()
|
|
24
|
+
]);
|
|
25
|
+
const contactSummarySchema = z.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
email: z.string(),
|
|
28
|
+
first_name: z.string().optional().nullable(),
|
|
29
|
+
last_name: z.string().optional().nullable(),
|
|
30
|
+
unsubscribed: z.boolean().optional(),
|
|
31
|
+
created_at: z.string().optional(),
|
|
32
|
+
updated_at: z.string().optional()
|
|
33
|
+
}).passthrough();
|
|
34
|
+
const contactDetailSchema = contactSummarySchema.extend({
|
|
35
|
+
properties: z.record(z.string(), contactPropertiesValueSchema).optional(),
|
|
36
|
+
segment_ids: z.array(z.string()).optional()
|
|
37
|
+
}).passthrough();
|
|
38
|
+
const segmentSummarySchema = z.object({
|
|
39
|
+
id: z.string(),
|
|
40
|
+
name: z.string().optional(),
|
|
41
|
+
created_at: z.string().optional()
|
|
42
|
+
}).passthrough();
|
|
43
|
+
const topicSubscriptionSchema = z.object({
|
|
44
|
+
topic_id: z.string().min(1),
|
|
45
|
+
status: topicSubscriptionStateSchema
|
|
46
|
+
});
|
|
47
|
+
const listContactsResponseSchema = resendListEnvelope(contactSummarySchema);
|
|
48
|
+
const listContactSegmentsResponseSchema = resendListEnvelope(segmentSummarySchema);
|
|
49
|
+
const contactTopicsResponseSchema = z.object({ data: z.array(z.object({
|
|
50
|
+
topic_id: z.string(),
|
|
51
|
+
status: topicSubscriptionStateSchema
|
|
52
|
+
}).passthrough()) }).passthrough();
|
|
53
|
+
const createContact = resendOperation({
|
|
54
|
+
id: "create_resend_contact",
|
|
55
|
+
name: "Create Resend Contact",
|
|
56
|
+
description: "Create a contact.",
|
|
57
|
+
input: z.object({
|
|
58
|
+
email: z.email(),
|
|
59
|
+
first_name: z.string().optional(),
|
|
60
|
+
last_name: z.string().optional(),
|
|
61
|
+
unsubscribed: z.boolean().optional(),
|
|
62
|
+
properties: z.record(z.string(), contactPropertiesValueSchema).optional(),
|
|
63
|
+
segment_ids: z.array(z.string().min(1)).optional(),
|
|
64
|
+
topic_subscriptions: z.array(topicSubscriptionSchema).optional()
|
|
65
|
+
}),
|
|
66
|
+
output: contactDetailSchema,
|
|
67
|
+
needsApproval: true,
|
|
68
|
+
run: async (input, credentials) => {
|
|
69
|
+
return createResendClient(credentials).request({
|
|
70
|
+
method: "POST",
|
|
71
|
+
path: "/contacts",
|
|
72
|
+
body: input
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const listContacts = resendOperation({
|
|
77
|
+
id: "list_resend_contacts",
|
|
78
|
+
name: "List Resend Contacts",
|
|
79
|
+
description: "List contacts, optionally filtered by segment.",
|
|
80
|
+
input: paginationQuerySchema.extend({ segment_id: z.string().min(1).optional() }),
|
|
81
|
+
output: listContactsResponseSchema,
|
|
82
|
+
run: async (input, credentials) => {
|
|
83
|
+
return createResendClient(credentials).request({
|
|
84
|
+
method: "GET",
|
|
85
|
+
path: "/contacts",
|
|
86
|
+
query: input
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
const retrieveContact = resendOperation({
|
|
91
|
+
id: "retrieve_resend_contact",
|
|
92
|
+
name: "Retrieve Resend Contact",
|
|
93
|
+
description: "Retrieve a contact by id or email.",
|
|
94
|
+
input: z.object({ id: z.string().min(1) }),
|
|
95
|
+
output: contactDetailSchema,
|
|
96
|
+
run: async (input, credentials) => {
|
|
97
|
+
return createResendClient(credentials).request({
|
|
98
|
+
method: "GET",
|
|
99
|
+
path: `/contacts/${encodeURIComponent(input.id)}`
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const updateContact = resendOperation({
|
|
104
|
+
id: "update_resend_contact",
|
|
105
|
+
name: "Update Resend Contact",
|
|
106
|
+
description: "Update an existing contact.",
|
|
107
|
+
input: z.object({
|
|
108
|
+
id: z.string().min(1),
|
|
109
|
+
email: z.email().optional(),
|
|
110
|
+
first_name: z.string().optional(),
|
|
111
|
+
last_name: z.string().optional(),
|
|
112
|
+
unsubscribed: z.boolean().optional(),
|
|
113
|
+
properties: z.record(z.string(), contactPropertiesValueSchema).optional()
|
|
114
|
+
}),
|
|
115
|
+
output: contactDetailSchema,
|
|
116
|
+
needsApproval: true,
|
|
117
|
+
run: async (input, credentials) => {
|
|
118
|
+
const { id, ...body } = input;
|
|
119
|
+
return createResendClient(credentials).request({
|
|
120
|
+
method: "PATCH",
|
|
121
|
+
path: `/contacts/${encodeURIComponent(id)}`,
|
|
122
|
+
body
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
const deleteContact = resendOperation({
|
|
127
|
+
id: "delete_resend_contact",
|
|
128
|
+
name: "Delete Resend Contact",
|
|
129
|
+
description: "Delete a contact.",
|
|
130
|
+
input: z.object({ id: z.string().min(1) }),
|
|
131
|
+
output: z.object({
|
|
132
|
+
object: z.literal("contact").optional(),
|
|
133
|
+
id: z.string(),
|
|
134
|
+
deleted: z.boolean().optional()
|
|
135
|
+
}).passthrough(),
|
|
136
|
+
needsApproval: true,
|
|
137
|
+
run: async (input, credentials) => {
|
|
138
|
+
return createResendClient(credentials).request({
|
|
139
|
+
method: "DELETE",
|
|
140
|
+
path: `/contacts/${encodeURIComponent(input.id)}`
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
const addContactToSegment = resendOperation({
|
|
145
|
+
id: "add_resend_contact_to_segment",
|
|
146
|
+
name: "Add Resend Contact to Segment",
|
|
147
|
+
description: "Add a contact to a segment.",
|
|
148
|
+
input: z.object({
|
|
149
|
+
contact_id: z.string().min(1),
|
|
150
|
+
segment_id: z.string().min(1)
|
|
151
|
+
}),
|
|
152
|
+
output: z.object({}).passthrough(),
|
|
153
|
+
needsApproval: true,
|
|
154
|
+
run: async (input, credentials) => {
|
|
155
|
+
return createResendClient(credentials).request({
|
|
156
|
+
method: "POST",
|
|
157
|
+
path: `/contacts/${encodeURIComponent(input.contact_id)}/segments/${encodeURIComponent(input.segment_id)}`
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const removeContactFromSegment = resendOperation({
|
|
162
|
+
id: "remove_resend_contact_from_segment",
|
|
163
|
+
name: "Remove Resend Contact from Segment",
|
|
164
|
+
description: "Remove a contact from a segment.",
|
|
165
|
+
input: z.object({
|
|
166
|
+
contact_id: z.string().min(1),
|
|
167
|
+
segment_id: z.string().min(1)
|
|
168
|
+
}),
|
|
169
|
+
output: z.object({}).passthrough(),
|
|
170
|
+
needsApproval: true,
|
|
171
|
+
run: async (input, credentials) => {
|
|
172
|
+
return createResendClient(credentials).request({
|
|
173
|
+
method: "DELETE",
|
|
174
|
+
path: `/contacts/${encodeURIComponent(input.contact_id)}/segments/${encodeURIComponent(input.segment_id)}`
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
const listContactSegments = resendOperation({
|
|
179
|
+
id: "list_resend_contact_segments",
|
|
180
|
+
name: "List Resend Contact Segments",
|
|
181
|
+
description: "List segments a contact belongs to.",
|
|
182
|
+
input: z.object({ contact_id: z.string().min(1) }),
|
|
183
|
+
output: listContactSegmentsResponseSchema,
|
|
184
|
+
run: async (input, credentials) => {
|
|
185
|
+
return createResendClient(credentials).request({
|
|
186
|
+
method: "GET",
|
|
187
|
+
path: `/contacts/${encodeURIComponent(input.contact_id)}/segments`
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
const getContactTopics = resendOperation({
|
|
192
|
+
id: "get_resend_contact_topics",
|
|
193
|
+
name: "Get Resend Contact Topics",
|
|
194
|
+
description: "List topic subscriptions for a contact.",
|
|
195
|
+
input: z.object({ contact_id: z.string().min(1) }),
|
|
196
|
+
output: contactTopicsResponseSchema,
|
|
197
|
+
run: async (input, credentials) => {
|
|
198
|
+
return createResendClient(credentials).request({
|
|
199
|
+
method: "GET",
|
|
200
|
+
path: `/contacts/${encodeURIComponent(input.contact_id)}/topics`
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
const updateContactTopics = resendOperation({
|
|
205
|
+
id: "update_resend_contact_topics",
|
|
206
|
+
name: "Update Resend Contact Topics",
|
|
207
|
+
description: "Update topic subscriptions for a contact.",
|
|
208
|
+
input: z.object({
|
|
209
|
+
contact_id: z.string().min(1),
|
|
210
|
+
subscriptions: z.array(topicSubscriptionSchema).min(1)
|
|
211
|
+
}),
|
|
212
|
+
output: contactTopicsResponseSchema,
|
|
213
|
+
needsApproval: true,
|
|
214
|
+
run: async (input, credentials) => {
|
|
215
|
+
const { contact_id, subscriptions } = input;
|
|
216
|
+
return createResendClient(credentials).request({
|
|
217
|
+
method: "PATCH",
|
|
218
|
+
path: `/contacts/${encodeURIComponent(contact_id)}/topics`,
|
|
219
|
+
body: { subscriptions }
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
//#endregion
|
|
225
|
+
export { addContactToSegment, createContact, deleteContact, getContactTopics, listContactSegments, listContacts, removeContactFromSegment, retrieveContact, updateContact, updateContactTopics };
|