@keystrokehq/sendgrid 0.0.15 → 0.0.16-integration-id-canonicalization.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +59 -111
  2. package/dist/credential-sets/index.d.mts +2 -0
  3. package/dist/credential-sets/index.mjs +3 -0
  4. package/dist/index.d.mts +4 -1
  5. package/dist/index.mjs +5 -1
  6. package/dist/operations/index.d.mts +2 -0
  7. package/dist/operations/index.mjs +3 -0
  8. package/dist/schemas/index.d.mts +5 -5
  9. package/dist/schemas/index.mjs +1 -1
  10. package/dist/{integration-DHWfpe0w.mjs → sendgrid.credential-set-CzYmlJ2Y.mjs} +9 -8
  11. package/dist/sendgrid.credential-set-ivRIiUDy.d.mts +32 -0
  12. package/dist/validate-email.operation-CCCDxLjH.mjs +4301 -0
  13. package/dist/validate-email.operation-DY4rCHFE.d.mts +5436 -0
  14. package/package.json +11 -99
  15. package/dist/_official/index.d.mts +0 -2
  16. package/dist/_official/index.mjs +0 -3
  17. package/dist/_runtime/index.d.mts +0 -2
  18. package/dist/_runtime/index.mjs +0 -3
  19. package/dist/alerts.d.mts +0 -147
  20. package/dist/alerts.mjs +0 -101
  21. package/dist/api-keys.d.mts +0 -105
  22. package/dist/api-keys.mjs +0 -113
  23. package/dist/client.d.mts +0 -73
  24. package/dist/client.mjs +0 -261
  25. package/dist/connection.d.mts +0 -2
  26. package/dist/connection.mjs +0 -3
  27. package/dist/domains.d.mts +0 -86
  28. package/dist/domains.mjs +0 -62
  29. package/dist/email-validation.d.mts +0 -97
  30. package/dist/email-validation.mjs +0 -73
  31. package/dist/events.d.mts +0 -69
  32. package/dist/events.mjs +0 -28
  33. package/dist/factory-7q6CQ75J.mjs +0 -25
  34. package/dist/integration-Cj4Xzfq_.d.mts +0 -48
  35. package/dist/mail-send.d.mts +0 -242
  36. package/dist/mail-send.mjs +0 -218
  37. package/dist/marketing-contacts.d.mts +0 -462
  38. package/dist/marketing-contacts.mjs +0 -277
  39. package/dist/marketing-customfields.d.mts +0 -66
  40. package/dist/marketing-customfields.mjs +0 -70
  41. package/dist/marketing-lists.d.mts +0 -120
  42. package/dist/marketing-lists.mjs +0 -130
  43. package/dist/marketing-segments.d.mts +0 -249
  44. package/dist/marketing-segments.mjs +0 -179
  45. package/dist/marketing-singlesends.d.mts +0 -521
  46. package/dist/marketing-singlesends.mjs +0 -277
  47. package/dist/operations.d.mts +0 -25
  48. package/dist/operations.mjs +0 -69
  49. package/dist/sender-identities.d.mts +0 -163
  50. package/dist/sender-identities.mjs +0 -109
  51. package/dist/senders.d.mts +0 -181
  52. package/dist/senders.mjs +0 -83
  53. package/dist/shared-CQ8JFNXi.mjs +0 -13
  54. package/dist/stats.d.mts +0 -169
  55. package/dist/stats.mjs +0 -107
  56. package/dist/suppressions.d.mts +0 -505
  57. package/dist/suppressions.mjs +0 -539
  58. package/dist/templates.d.mts +0 -351
  59. package/dist/templates.mjs +0 -238
  60. package/dist/user-account.d.mts +0 -71
  61. package/dist/user-account.mjs +0 -59
  62. package/dist/verification.d.mts +0 -67
  63. package/dist/verification.mjs +0 -72
  64. package/dist/webhooks/event.d.mts +0 -214
  65. package/dist/webhooks/event.mjs +0 -147
  66. package/dist/webhooks/parse.d.mts +0 -117
  67. package/dist/webhooks/parse.mjs +0 -125
  68. /package/dist/{webhooks-CKdsIikb.mjs → webhooks-dVOd93Hd.mjs} +0 -0
@@ -1,249 +0,0 @@
1
- import { z } from "zod";
2
- import * as _keystrokehq_core0 from "@keystrokehq/core";
3
-
4
- //#region src/marketing-segments.d.ts
5
- declare const createSegment: _keystrokehq_core0.Operation<z.ZodObject<{
6
- name: z.ZodString;
7
- parentListIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
8
- queryDsl: z.ZodString;
9
- }, z.core.$strip>, z.ZodObject<{
10
- id: z.ZodString;
11
- name: z.ZodString;
12
- query_dsl: z.ZodOptional<z.ZodString>;
13
- query_version: z.ZodOptional<z.ZodString>;
14
- parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
- contacts_count: z.ZodOptional<z.ZodNumber>;
16
- contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
17
- created_at: z.ZodOptional<z.ZodISODateTime>;
18
- updated_at: z.ZodOptional<z.ZodISODateTime>;
19
- next_sample_update: z.ZodOptional<z.ZodISODateTime>;
20
- status: z.ZodOptional<z.ZodObject<{
21
- query_validation: z.ZodOptional<z.ZodString>;
22
- error_message: z.ZodOptional<z.ZodString>;
23
- }, z.core.$catchall<z.ZodUnknown>>>;
24
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
25
- SENDGRID_API_KEY: z.ZodString;
26
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
27
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
28
- global: "global";
29
- eu: "eu";
30
- }>>;
31
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
32
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
33
- }, z.core.$strip>>], undefined>;
34
- declare const updateSegment: _keystrokehq_core0.Operation<z.ZodObject<{
35
- segmentId: z.ZodString;
36
- name: z.ZodOptional<z.ZodString>;
37
- queryDsl: z.ZodOptional<z.ZodString>;
38
- }, z.core.$strip>, z.ZodObject<{
39
- id: z.ZodString;
40
- name: z.ZodString;
41
- query_dsl: z.ZodOptional<z.ZodString>;
42
- query_version: z.ZodOptional<z.ZodString>;
43
- parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
44
- contacts_count: z.ZodOptional<z.ZodNumber>;
45
- contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
46
- created_at: z.ZodOptional<z.ZodISODateTime>;
47
- updated_at: z.ZodOptional<z.ZodISODateTime>;
48
- next_sample_update: z.ZodOptional<z.ZodISODateTime>;
49
- status: z.ZodOptional<z.ZodObject<{
50
- query_validation: z.ZodOptional<z.ZodString>;
51
- error_message: z.ZodOptional<z.ZodString>;
52
- }, z.core.$catchall<z.ZodUnknown>>>;
53
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
54
- SENDGRID_API_KEY: z.ZodString;
55
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
56
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
57
- global: "global";
58
- eu: "eu";
59
- }>>;
60
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
61
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
62
- }, z.core.$strip>>], undefined>;
63
- declare const deleteSegment: _keystrokehq_core0.Operation<z.ZodObject<{
64
- segmentId: z.ZodString;
65
- }, z.core.$strip>, z.ZodObject<{
66
- success: z.ZodBoolean;
67
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
68
- SENDGRID_API_KEY: z.ZodString;
69
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
70
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
71
- global: "global";
72
- eu: "eu";
73
- }>>;
74
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
75
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
76
- }, z.core.$strip>>], undefined>;
77
- declare const listSegments: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodObject<{
78
- parentListIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
79
- noParentListId: z.ZodOptional<z.ZodBoolean>;
80
- }, z.core.$strip>>, z.ZodObject<{
81
- results: z.ZodArray<z.ZodObject<{
82
- id: z.ZodString;
83
- name: z.ZodString;
84
- query_dsl: z.ZodOptional<z.ZodString>;
85
- query_version: z.ZodOptional<z.ZodString>;
86
- parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
87
- contacts_count: z.ZodOptional<z.ZodNumber>;
88
- contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
89
- created_at: z.ZodOptional<z.ZodISODateTime>;
90
- updated_at: z.ZodOptional<z.ZodISODateTime>;
91
- next_sample_update: z.ZodOptional<z.ZodISODateTime>;
92
- status: z.ZodOptional<z.ZodObject<{
93
- query_validation: z.ZodOptional<z.ZodString>;
94
- error_message: z.ZodOptional<z.ZodString>;
95
- }, z.core.$catchall<z.ZodUnknown>>>;
96
- }, z.core.$catchall<z.ZodUnknown>>>;
97
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
98
- SENDGRID_API_KEY: z.ZodString;
99
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
100
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
101
- global: "global";
102
- eu: "eu";
103
- }>>;
104
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
105
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
106
- }, z.core.$strip>>], undefined>;
107
- declare const getSegment: _keystrokehq_core0.Operation<z.ZodObject<{
108
- segmentId: z.ZodString;
109
- contactsSample: z.ZodOptional<z.ZodBoolean>;
110
- }, z.core.$strip>, z.ZodObject<{
111
- id: z.ZodString;
112
- name: z.ZodString;
113
- query_dsl: z.ZodOptional<z.ZodString>;
114
- query_version: z.ZodOptional<z.ZodString>;
115
- parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
116
- contacts_count: z.ZodOptional<z.ZodNumber>;
117
- contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
118
- created_at: z.ZodOptional<z.ZodISODateTime>;
119
- updated_at: z.ZodOptional<z.ZodISODateTime>;
120
- next_sample_update: z.ZodOptional<z.ZodISODateTime>;
121
- status: z.ZodOptional<z.ZodObject<{
122
- query_validation: z.ZodOptional<z.ZodString>;
123
- error_message: z.ZodOptional<z.ZodString>;
124
- }, z.core.$catchall<z.ZodUnknown>>>;
125
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
126
- SENDGRID_API_KEY: z.ZodString;
127
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
128
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
129
- global: "global";
130
- eu: "eu";
131
- }>>;
132
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
133
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
134
- }, z.core.$strip>>], undefined>;
135
- declare const refreshSegment: _keystrokehq_core0.Operation<z.ZodObject<{
136
- segmentId: z.ZodString;
137
- }, z.core.$strip>, z.ZodObject<{
138
- id: z.ZodString;
139
- name: z.ZodString;
140
- query_dsl: z.ZodOptional<z.ZodString>;
141
- query_version: z.ZodOptional<z.ZodString>;
142
- parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
143
- contacts_count: z.ZodOptional<z.ZodNumber>;
144
- contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
145
- created_at: z.ZodOptional<z.ZodISODateTime>;
146
- updated_at: z.ZodOptional<z.ZodISODateTime>;
147
- next_sample_update: z.ZodOptional<z.ZodISODateTime>;
148
- status: z.ZodOptional<z.ZodObject<{
149
- query_validation: z.ZodOptional<z.ZodString>;
150
- error_message: z.ZodOptional<z.ZodString>;
151
- }, z.core.$catchall<z.ZodUnknown>>>;
152
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
153
- SENDGRID_API_KEY: z.ZodString;
154
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
155
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
156
- global: "global";
157
- eu: "eu";
158
- }>>;
159
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
160
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
161
- }, z.core.$strip>>], undefined>;
162
- declare const filterSegmentsByParents: _keystrokehq_core0.Operation<z.ZodObject<{
163
- parentListIds: z.ZodArray<z.ZodString>;
164
- }, z.core.$strip>, z.ZodObject<{
165
- results: z.ZodArray<z.ZodObject<{
166
- id: z.ZodString;
167
- name: z.ZodString;
168
- query_dsl: z.ZodOptional<z.ZodString>;
169
- query_version: z.ZodOptional<z.ZodString>;
170
- parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
171
- contacts_count: z.ZodOptional<z.ZodNumber>;
172
- contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
173
- created_at: z.ZodOptional<z.ZodISODateTime>;
174
- updated_at: z.ZodOptional<z.ZodISODateTime>;
175
- next_sample_update: z.ZodOptional<z.ZodISODateTime>;
176
- status: z.ZodOptional<z.ZodObject<{
177
- query_validation: z.ZodOptional<z.ZodString>;
178
- error_message: z.ZodOptional<z.ZodString>;
179
- }, z.core.$catchall<z.ZodUnknown>>>;
180
- }, z.core.$catchall<z.ZodUnknown>>>;
181
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
182
- SENDGRID_API_KEY: z.ZodString;
183
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
184
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
185
- global: "global";
186
- eu: "eu";
187
- }>>;
188
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
189
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
190
- }, z.core.$strip>>], undefined>;
191
- declare const createLegacySegment: _keystrokehq_core0.Operation<z.ZodObject<{
192
- name: z.ZodString;
193
- parentListIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
194
- queryDsl: z.ZodString;
195
- }, z.core.$strip>, z.ZodObject<{
196
- id: z.ZodString;
197
- name: z.ZodString;
198
- query_dsl: z.ZodOptional<z.ZodString>;
199
- query_version: z.ZodOptional<z.ZodString>;
200
- parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
201
- contacts_count: z.ZodOptional<z.ZodNumber>;
202
- contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
203
- created_at: z.ZodOptional<z.ZodISODateTime>;
204
- updated_at: z.ZodOptional<z.ZodISODateTime>;
205
- next_sample_update: z.ZodOptional<z.ZodISODateTime>;
206
- status: z.ZodOptional<z.ZodObject<{
207
- query_validation: z.ZodOptional<z.ZodString>;
208
- error_message: z.ZodOptional<z.ZodString>;
209
- }, z.core.$catchall<z.ZodUnknown>>>;
210
- }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
211
- SENDGRID_API_KEY: z.ZodString;
212
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
213
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
214
- global: "global";
215
- eu: "eu";
216
- }>>;
217
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
218
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
219
- }, z.core.$strip>>], undefined>;
220
- declare const deleteLegacySegment: _keystrokehq_core0.Operation<z.ZodObject<{
221
- segmentId: z.ZodString;
222
- }, z.core.$strip>, z.ZodObject<{
223
- success: z.ZodBoolean;
224
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
225
- SENDGRID_API_KEY: z.ZodString;
226
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
227
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
228
- global: "global";
229
- eu: "eu";
230
- }>>;
231
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
232
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
233
- }, z.core.$strip>>], undefined>;
234
- declare const removeSegmentWithoutContacts: _keystrokehq_core0.Operation<z.ZodObject<{
235
- segmentId: z.ZodString;
236
- }, z.core.$strip>, z.ZodObject<{
237
- success: z.ZodBoolean;
238
- }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"keystroke:sendgrid", z.ZodObject<{
239
- SENDGRID_API_KEY: z.ZodString;
240
- SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
241
- SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
242
- global: "global";
243
- eu: "eu";
244
- }>>;
245
- SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
246
- SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
247
- }, z.core.$strip>>], undefined>;
248
- //#endregion
249
- export { createLegacySegment, createSegment, deleteLegacySegment, deleteSegment, filterSegmentsByParents, getSegment, listSegments, refreshSegment, removeSegmentWithoutContacts, updateSegment };
@@ -1,179 +0,0 @@
1
- import { n as __exportAll, t as sendgridOperation } from "./factory-7q6CQ75J.mjs";
2
- import { n as omitUndefined } from "./shared-CQ8JFNXi.mjs";
3
- import { createSendGridClient } from "./client.mjs";
4
- import { at as sendgridSegmentListSchema, on as sendgridIdSchema, ot as sendgridSegmentSchema } from "./webhooks-CKdsIikb.mjs";
5
- import { z } from "zod";
6
-
7
- //#region src/marketing-segments.ts
8
- var marketing_segments_exports = /* @__PURE__ */ __exportAll({
9
- createLegacySegment: () => createLegacySegment,
10
- createSegment: () => createSegment,
11
- deleteLegacySegment: () => deleteLegacySegment,
12
- deleteSegment: () => deleteSegment,
13
- filterSegmentsByParents: () => filterSegmentsByParents,
14
- getSegment: () => getSegment,
15
- listSegments: () => listSegments,
16
- refreshSegment: () => refreshSegment,
17
- removeSegmentWithoutContacts: () => removeSegmentWithoutContacts,
18
- updateSegment: () => updateSegment
19
- });
20
- const segmentBody = z.object({
21
- name: z.string().min(1),
22
- parentListIds: z.array(sendgridIdSchema).optional(),
23
- queryDsl: z.string().min(1)
24
- });
25
- function mapSegmentBody(body) {
26
- return omitUndefined({
27
- name: body.name,
28
- parent_list_ids: body.parentListIds,
29
- query_dsl: body.queryDsl
30
- });
31
- }
32
- const createSegment = sendgridOperation({
33
- id: "sendgrid.create-segment",
34
- name: "Create Segment",
35
- description: "Create a Marketing Segments v2.0 segment.",
36
- input: segmentBody,
37
- output: sendgridSegmentSchema,
38
- needsApproval: true,
39
- run: async (input, credentials) => {
40
- const response = await createSendGridClient(credentials).request("/marketing/segments/2.0", {
41
- method: "POST",
42
- body: mapSegmentBody(input)
43
- });
44
- return sendgridSegmentSchema.parse(response);
45
- }
46
- });
47
- const updateSegment = sendgridOperation({
48
- id: "sendgrid.update-segment",
49
- name: "Update Segment",
50
- description: "Update a v2.0 segment.",
51
- input: z.object({
52
- segmentId: sendgridIdSchema,
53
- name: z.string().min(1).optional(),
54
- queryDsl: z.string().min(1).optional()
55
- }),
56
- output: sendgridSegmentSchema,
57
- needsApproval: true,
58
- run: async (input, credentials) => {
59
- const response = await createSendGridClient(credentials).request(`/marketing/segments/2.0/${encodeURIComponent(input.segmentId)}`, {
60
- method: "PATCH",
61
- body: omitUndefined({
62
- name: input.name,
63
- query_dsl: input.queryDsl
64
- })
65
- });
66
- return sendgridSegmentSchema.parse(response);
67
- }
68
- });
69
- const deleteSegment = sendgridOperation({
70
- id: "sendgrid.delete-segment",
71
- name: "Delete Segment",
72
- description: "Delete a v2.0 segment. Contacts remain.",
73
- input: z.object({ segmentId: sendgridIdSchema }),
74
- output: z.object({ success: z.boolean() }),
75
- needsApproval: true,
76
- run: async (input, credentials) => {
77
- await createSendGridClient(credentials).request(`/marketing/segments/2.0/${encodeURIComponent(input.segmentId)}`, { method: "DELETE" });
78
- return { success: true };
79
- }
80
- });
81
- const listSegments = sendgridOperation({
82
- id: "sendgrid.list-segments",
83
- name: "List Segments",
84
- description: "List v2.0 segments. Filter by parent list IDs.",
85
- input: z.object({
86
- parentListIds: z.array(sendgridIdSchema).optional(),
87
- noParentListId: z.boolean().optional()
88
- }).optional(),
89
- output: sendgridSegmentListSchema,
90
- run: async (input, credentials) => {
91
- const response = await createSendGridClient(credentials).request("/marketing/segments/2.0", { query: omitUndefined({
92
- parent_list_ids: input?.parentListIds?.join(","),
93
- no_parent_list_id: input?.noParentListId ? "true" : void 0
94
- }) });
95
- return sendgridSegmentListSchema.parse(response ?? { results: [] });
96
- }
97
- });
98
- const getSegment = sendgridOperation({
99
- id: "sendgrid.get-segment",
100
- name: "Get Segment",
101
- description: "Retrieve a v2.0 segment by ID.",
102
- input: z.object({
103
- segmentId: sendgridIdSchema,
104
- contactsSample: z.boolean().optional()
105
- }),
106
- output: sendgridSegmentSchema,
107
- run: async (input, credentials) => {
108
- const response = await createSendGridClient(credentials).request(`/marketing/segments/2.0/${encodeURIComponent(input.segmentId)}`, { query: omitUndefined({ contacts_sample: input.contactsSample ? "true" : void 0 }) });
109
- return sendgridSegmentSchema.parse(response);
110
- }
111
- });
112
- const refreshSegment = sendgridOperation({
113
- id: "sendgrid.refresh-segment",
114
- name: "Refresh Segment",
115
- description: "Manually refresh a v2.0 segment to re-evaluate its membership.",
116
- input: z.object({ segmentId: sendgridIdSchema }),
117
- output: sendgridSegmentSchema,
118
- needsApproval: true,
119
- run: async (input, credentials) => {
120
- const response = await createSendGridClient(credentials).request(`/marketing/segments/2.0/${encodeURIComponent(input.segmentId)}/refresh`, { method: "POST" });
121
- return sendgridSegmentSchema.parse(response);
122
- }
123
- });
124
- const filterSegmentsByParents = sendgridOperation({
125
- id: "sendgrid.filter-segments-by-parent-ids",
126
- name: "Filter Segments by Parent List IDs",
127
- description: "List segments whose parent list matches any of the given IDs.",
128
- input: z.object({ parentListIds: z.array(sendgridIdSchema).min(1) }),
129
- output: sendgridSegmentListSchema,
130
- run: async (input, credentials) => {
131
- const response = await createSendGridClient(credentials).request("/marketing/segments/2.0", { query: { parent_list_ids: input.parentListIds.join(",") } });
132
- return sendgridSegmentListSchema.parse(response ?? { results: [] });
133
- }
134
- });
135
- const createLegacySegment = sendgridOperation({
136
- id: "sendgrid.create-legacy-marketing-segment",
137
- name: "Create Marketing Segment (v1 engine)",
138
- description: "Create a segment using the v1 engine. Kept because some accounts still run v1; new code should prefer `createSegment`.",
139
- input: segmentBody,
140
- output: sendgridSegmentSchema,
141
- needsApproval: true,
142
- run: async (input, credentials) => {
143
- const response = await createSendGridClient(credentials).request("/marketing/segments", {
144
- method: "POST",
145
- body: mapSegmentBody(input)
146
- });
147
- return sendgridSegmentSchema.parse(response);
148
- }
149
- });
150
- const deleteLegacySegment = sendgridOperation({
151
- id: "sendgrid.delete-legacy-marketing-segment",
152
- name: "Delete Marketing Segment (v1 engine)",
153
- description: "Delete a v1-engine segment.",
154
- input: z.object({ segmentId: sendgridIdSchema }),
155
- output: z.object({ success: z.boolean() }),
156
- needsApproval: true,
157
- run: async (input, credentials) => {
158
- await createSendGridClient(credentials).request(`/marketing/segments/${encodeURIComponent(input.segmentId)}`, { method: "DELETE" });
159
- return { success: true };
160
- }
161
- });
162
- const removeSegmentWithoutContacts = sendgridOperation({
163
- id: "sendgrid.remove-segment-without-affecting-contacts",
164
- name: "Remove Segment Without Affecting Contacts",
165
- description: "Delete a v2.0 segment without removing any contacts.",
166
- input: z.object({ segmentId: sendgridIdSchema }),
167
- output: z.object({ success: z.boolean() }),
168
- needsApproval: true,
169
- run: async (input, credentials) => {
170
- await createSendGridClient(credentials).request(`/marketing/segments/2.0/${encodeURIComponent(input.segmentId)}`, {
171
- method: "DELETE",
172
- query: { contacts: "false" }
173
- });
174
- return { success: true };
175
- }
176
- });
177
-
178
- //#endregion
179
- export { createLegacySegment, createSegment, deleteLegacySegment, deleteSegment, filterSegmentsByParents, getSegment, listSegments, refreshSegment, removeSegmentWithoutContacts, marketing_segments_exports as t, updateSegment };