@keystrokehq/sendgrid 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.
Files changed (63) hide show
  1. package/README.md +225 -0
  2. package/dist/_official/index.d.mts +2 -0
  3. package/dist/_official/index.mjs +3 -0
  4. package/dist/_runtime/index.d.mts +2 -0
  5. package/dist/_runtime/index.mjs +3 -0
  6. package/dist/alerts.d.mts +193 -0
  7. package/dist/alerts.mjs +101 -0
  8. package/dist/api-keys.d.mts +160 -0
  9. package/dist/api-keys.mjs +113 -0
  10. package/dist/client.d.mts +73 -0
  11. package/dist/client.mjs +261 -0
  12. package/dist/connection.d.mts +2 -0
  13. package/dist/connection.mjs +3 -0
  14. package/dist/domains.d.mts +114 -0
  15. package/dist/domains.mjs +62 -0
  16. package/dist/email-validation.d.mts +134 -0
  17. package/dist/email-validation.mjs +73 -0
  18. package/dist/events.d.mts +69 -0
  19. package/dist/events.mjs +28 -0
  20. package/dist/factory-BSL0D2L0.mjs +25 -0
  21. package/dist/index.d.mts +1 -0
  22. package/dist/index.mjs +1 -0
  23. package/dist/integration-37BovSeK.mjs +23 -0
  24. package/dist/integration-CmJ2TILG.d.mts +57 -0
  25. package/dist/mail-send.d.mts +315 -0
  26. package/dist/mail-send.mjs +218 -0
  27. package/dist/marketing-contacts.d.mts +607 -0
  28. package/dist/marketing-contacts.mjs +277 -0
  29. package/dist/marketing-customfields.d.mts +94 -0
  30. package/dist/marketing-customfields.mjs +70 -0
  31. package/dist/marketing-lists.d.mts +184 -0
  32. package/dist/marketing-lists.mjs +130 -0
  33. package/dist/marketing-segments.d.mts +340 -0
  34. package/dist/marketing-segments.mjs +179 -0
  35. package/dist/marketing-singlesends.d.mts +648 -0
  36. package/dist/marketing-singlesends.mjs +277 -0
  37. package/dist/operations.d.mts +25 -0
  38. package/dist/operations.mjs +69 -0
  39. package/dist/schemas/index.d.mts +1395 -0
  40. package/dist/schemas/index.mjs +3 -0
  41. package/dist/sender-identities.d.mts +218 -0
  42. package/dist/sender-identities.mjs +109 -0
  43. package/dist/senders.d.mts +227 -0
  44. package/dist/senders.mjs +83 -0
  45. package/dist/shared-CQ8JFNXi.mjs +13 -0
  46. package/dist/stats.d.mts +215 -0
  47. package/dist/stats.mjs +107 -0
  48. package/dist/suppressions.d.mts +785 -0
  49. package/dist/suppressions.mjs +539 -0
  50. package/dist/templates.d.mts +451 -0
  51. package/dist/templates.mjs +238 -0
  52. package/dist/triggers.d.mts +35 -0
  53. package/dist/triggers.mjs +98 -0
  54. package/dist/user-account.d.mts +108 -0
  55. package/dist/user-account.mjs +59 -0
  56. package/dist/verification.d.mts +67 -0
  57. package/dist/verification.mjs +72 -0
  58. package/dist/webhooks/event.d.mts +287 -0
  59. package/dist/webhooks/event.mjs +147 -0
  60. package/dist/webhooks/parse.d.mts +172 -0
  61. package/dist/webhooks/parse.mjs +125 -0
  62. package/dist/webhooks-CKdsIikb.mjs +735 -0
  63. package/package.json +162 -0
@@ -0,0 +1,130 @@
1
+ import { n as __exportAll, t as sendgridOperation } from "./factory-BSL0D2L0.mjs";
2
+ import { n as omitUndefined } from "./shared-CQ8JFNXi.mjs";
3
+ import { createSendGridClient } from "./client.mjs";
4
+ import { Ct as sendgridListSchema, St as sendgridListRemoveContactsResultSchema, bt as sendgridListCollectionSchema, on as sendgridIdSchema, xt as sendgridListContactCountSchema } from "./webhooks-CKdsIikb.mjs";
5
+ import { z } from "zod";
6
+
7
+ //#region src/marketing-lists.ts
8
+ var marketing_lists_exports = /* @__PURE__ */ __exportAll({
9
+ createList: () => createList,
10
+ deleteList: () => deleteList,
11
+ getList: () => getList,
12
+ getListContactCount: () => getListContactCount,
13
+ listMarketingLists: () => listMarketingLists,
14
+ removeContactsFromList: () => removeContactsFromList,
15
+ updateList: () => updateList
16
+ });
17
+ const createList = sendgridOperation({
18
+ id: "create_list",
19
+ name: "Create Marketing List",
20
+ description: "Create a new v3 marketing list.",
21
+ input: z.object({ name: z.string().min(1) }),
22
+ output: sendgridListSchema,
23
+ needsApproval: true,
24
+ run: async (input, credentials) => {
25
+ const response = await createSendGridClient(credentials).request("/marketing/lists", {
26
+ method: "POST",
27
+ body: { name: input.name }
28
+ });
29
+ return sendgridListSchema.parse(response);
30
+ }
31
+ });
32
+ const updateList = sendgridOperation({
33
+ id: "update_list",
34
+ name: "Update Marketing List",
35
+ description: "Rename a v3 marketing list.",
36
+ input: z.object({
37
+ listId: sendgridIdSchema,
38
+ name: z.string().min(1)
39
+ }),
40
+ output: sendgridListSchema,
41
+ needsApproval: true,
42
+ run: async (input, credentials) => {
43
+ const response = await createSendGridClient(credentials).request(`/marketing/lists/${encodeURIComponent(input.listId)}`, {
44
+ method: "PATCH",
45
+ body: { name: input.name }
46
+ });
47
+ return sendgridListSchema.parse(response);
48
+ }
49
+ });
50
+ const listMarketingLists = sendgridOperation({
51
+ id: "list_marketing_lists",
52
+ name: "List Marketing Lists",
53
+ description: "List all v3 marketing lists.",
54
+ input: z.object({
55
+ pageSize: z.number().int().positive().max(1e3).optional(),
56
+ pageToken: z.string().min(1).optional()
57
+ }).optional(),
58
+ output: sendgridListCollectionSchema,
59
+ run: async (input, credentials) => {
60
+ const response = await createSendGridClient(credentials).request("/marketing/lists", { query: omitUndefined({
61
+ page_size: input?.pageSize,
62
+ page_token: input?.pageToken
63
+ }) });
64
+ return sendgridListCollectionSchema.parse(response ?? { result: [] });
65
+ }
66
+ });
67
+ const getList = sendgridOperation({
68
+ id: "get_list",
69
+ name: "Get Marketing List",
70
+ description: "Retrieve a v3 marketing list by ID.",
71
+ input: z.object({
72
+ listId: sendgridIdSchema,
73
+ contactSampleSize: z.number().int().min(0).max(5).optional()
74
+ }),
75
+ output: sendgridListSchema,
76
+ run: async (input, credentials) => {
77
+ const response = await createSendGridClient(credentials).request(`/marketing/lists/${encodeURIComponent(input.listId)}`, { query: omitUndefined({ contact_sample: input.contactSampleSize }) });
78
+ return sendgridListSchema.parse(response);
79
+ }
80
+ });
81
+ const getListContactCount = sendgridOperation({
82
+ id: "get_list_contact_count",
83
+ name: "Get List Contact Count",
84
+ description: "Return the number of contacts on a marketing list.",
85
+ input: z.object({ listId: sendgridIdSchema }),
86
+ output: sendgridListContactCountSchema,
87
+ run: async (input, credentials) => {
88
+ const response = await createSendGridClient(credentials).request(`/marketing/lists/${encodeURIComponent(input.listId)}/contacts/count`);
89
+ return sendgridListContactCountSchema.parse(response);
90
+ }
91
+ });
92
+ const removeContactsFromList = sendgridOperation({
93
+ id: "remove_contacts_from_list",
94
+ name: "Remove Contacts from List",
95
+ description: "Remove the given contact IDs from a list. Contacts remain in the account (use deleteContacts to purge).",
96
+ input: z.object({
97
+ listId: sendgridIdSchema,
98
+ contactIds: z.array(sendgridIdSchema).min(1).max(100)
99
+ }),
100
+ output: sendgridListRemoveContactsResultSchema,
101
+ needsApproval: true,
102
+ run: async (input, credentials) => {
103
+ const response = await createSendGridClient(credentials).request(`/marketing/lists/${encodeURIComponent(input.listId)}/contacts`, {
104
+ method: "DELETE",
105
+ query: { contact_ids: input.contactIds.join(",") }
106
+ });
107
+ return sendgridListRemoveContactsResultSchema.parse(response);
108
+ }
109
+ });
110
+ const deleteList = sendgridOperation({
111
+ id: "delete_list",
112
+ name: "Delete Marketing List",
113
+ description: "Delete a marketing list. Set `deleteContacts: true` to also delete contacts only on this list.",
114
+ input: z.object({
115
+ listId: sendgridIdSchema,
116
+ deleteContacts: z.boolean().optional()
117
+ }),
118
+ output: z.object({ success: z.boolean() }),
119
+ needsApproval: true,
120
+ run: async (input, credentials) => {
121
+ await createSendGridClient(credentials).request(`/marketing/lists/${encodeURIComponent(input.listId)}`, {
122
+ method: "DELETE",
123
+ query: omitUndefined({ delete_contacts: input.deleteContacts ? "true" : void 0 })
124
+ });
125
+ return { success: true };
126
+ }
127
+ });
128
+
129
+ //#endregion
130
+ export { createList, deleteList, getList, getListContactCount, listMarketingLists, removeContactsFromList, marketing_lists_exports as t, updateList };
@@ -0,0 +1,340 @@
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/marketing-segments.d.ts
6
+ declare const createSegment: _keystrokehq_core0.Operation<z.ZodObject<{
7
+ name: z.ZodString;
8
+ parentListIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
9
+ queryDsl: z.ZodString;
10
+ }, z.core.$strip>, z.ZodObject<{
11
+ id: z.ZodString;
12
+ name: z.ZodString;
13
+ query_dsl: z.ZodOptional<z.ZodString>;
14
+ query_version: z.ZodOptional<z.ZodString>;
15
+ parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
16
+ contacts_count: z.ZodOptional<z.ZodNumber>;
17
+ contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
18
+ created_at: z.ZodOptional<z.ZodISODateTime>;
19
+ updated_at: z.ZodOptional<z.ZodISODateTime>;
20
+ next_sample_update: z.ZodOptional<z.ZodISODateTime>;
21
+ status: z.ZodOptional<z.ZodObject<{
22
+ query_validation: z.ZodOptional<z.ZodString>;
23
+ error_message: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$catchall<z.ZodUnknown>>>;
25
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
26
+ SENDGRID_API_KEY: z.ZodString;
27
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
28
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
29
+ global: "global";
30
+ eu: "eu";
31
+ }>>;
32
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
33
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
35
+ SENDGRID_API_KEY: z.ZodString;
36
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
37
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
38
+ global: "global";
39
+ eu: "eu";
40
+ }>>;
41
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
42
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
43
+ }, z.core.$strip>>[] | undefined>], undefined>;
44
+ declare const updateSegment: _keystrokehq_core0.Operation<z.ZodObject<{
45
+ segmentId: z.ZodString;
46
+ name: z.ZodOptional<z.ZodString>;
47
+ queryDsl: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>, z.ZodObject<{
49
+ id: z.ZodString;
50
+ name: z.ZodString;
51
+ query_dsl: z.ZodOptional<z.ZodString>;
52
+ query_version: z.ZodOptional<z.ZodString>;
53
+ parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
54
+ contacts_count: z.ZodOptional<z.ZodNumber>;
55
+ contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
56
+ created_at: z.ZodOptional<z.ZodISODateTime>;
57
+ updated_at: z.ZodOptional<z.ZodISODateTime>;
58
+ next_sample_update: z.ZodOptional<z.ZodISODateTime>;
59
+ status: z.ZodOptional<z.ZodObject<{
60
+ query_validation: z.ZodOptional<z.ZodString>;
61
+ error_message: z.ZodOptional<z.ZodString>;
62
+ }, z.core.$catchall<z.ZodUnknown>>>;
63
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
64
+ SENDGRID_API_KEY: z.ZodString;
65
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
66
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
67
+ global: "global";
68
+ eu: "eu";
69
+ }>>;
70
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
71
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
72
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
73
+ SENDGRID_API_KEY: z.ZodString;
74
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
75
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
76
+ global: "global";
77
+ eu: "eu";
78
+ }>>;
79
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
80
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
81
+ }, z.core.$strip>>[] | undefined>], undefined>;
82
+ declare const deleteSegment: _keystrokehq_core0.Operation<z.ZodObject<{
83
+ segmentId: z.ZodString;
84
+ }, z.core.$strip>, z.ZodObject<{
85
+ success: z.ZodBoolean;
86
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
87
+ SENDGRID_API_KEY: z.ZodString;
88
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
89
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
90
+ global: "global";
91
+ eu: "eu";
92
+ }>>;
93
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
94
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
95
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
96
+ SENDGRID_API_KEY: z.ZodString;
97
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
98
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
99
+ global: "global";
100
+ eu: "eu";
101
+ }>>;
102
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
103
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
104
+ }, z.core.$strip>>[] | undefined>], undefined>;
105
+ declare const listSegments: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodObject<{
106
+ parentListIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
107
+ noParentListId: z.ZodOptional<z.ZodBoolean>;
108
+ }, z.core.$strip>>, z.ZodObject<{
109
+ results: z.ZodArray<z.ZodObject<{
110
+ id: z.ZodString;
111
+ name: z.ZodString;
112
+ query_dsl: z.ZodOptional<z.ZodString>;
113
+ query_version: z.ZodOptional<z.ZodString>;
114
+ parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
115
+ contacts_count: z.ZodOptional<z.ZodNumber>;
116
+ contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
117
+ created_at: z.ZodOptional<z.ZodISODateTime>;
118
+ updated_at: z.ZodOptional<z.ZodISODateTime>;
119
+ next_sample_update: z.ZodOptional<z.ZodISODateTime>;
120
+ status: z.ZodOptional<z.ZodObject<{
121
+ query_validation: z.ZodOptional<z.ZodString>;
122
+ error_message: z.ZodOptional<z.ZodString>;
123
+ }, z.core.$catchall<z.ZodUnknown>>>;
124
+ }, z.core.$catchall<z.ZodUnknown>>>;
125
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"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>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
135
+ SENDGRID_API_KEY: z.ZodString;
136
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
137
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
138
+ global: "global";
139
+ eu: "eu";
140
+ }>>;
141
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
142
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
143
+ }, z.core.$strip>>[] | undefined>], undefined>;
144
+ declare const getSegment: _keystrokehq_core0.Operation<z.ZodObject<{
145
+ segmentId: z.ZodString;
146
+ contactsSample: z.ZodOptional<z.ZodBoolean>;
147
+ }, z.core.$strip>, z.ZodObject<{
148
+ id: z.ZodString;
149
+ name: z.ZodString;
150
+ query_dsl: z.ZodOptional<z.ZodString>;
151
+ query_version: z.ZodOptional<z.ZodString>;
152
+ parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
153
+ contacts_count: z.ZodOptional<z.ZodNumber>;
154
+ contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
155
+ created_at: z.ZodOptional<z.ZodISODateTime>;
156
+ updated_at: z.ZodOptional<z.ZodISODateTime>;
157
+ next_sample_update: z.ZodOptional<z.ZodISODateTime>;
158
+ status: z.ZodOptional<z.ZodObject<{
159
+ query_validation: z.ZodOptional<z.ZodString>;
160
+ error_message: z.ZodOptional<z.ZodString>;
161
+ }, z.core.$catchall<z.ZodUnknown>>>;
162
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
163
+ SENDGRID_API_KEY: z.ZodString;
164
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
165
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
166
+ global: "global";
167
+ eu: "eu";
168
+ }>>;
169
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
170
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
171
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
172
+ SENDGRID_API_KEY: z.ZodString;
173
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
174
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
175
+ global: "global";
176
+ eu: "eu";
177
+ }>>;
178
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
179
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
180
+ }, z.core.$strip>>[] | undefined>], undefined>;
181
+ declare const refreshSegment: _keystrokehq_core0.Operation<z.ZodObject<{
182
+ segmentId: z.ZodString;
183
+ }, z.core.$strip>, z.ZodObject<{
184
+ id: z.ZodString;
185
+ name: z.ZodString;
186
+ query_dsl: z.ZodOptional<z.ZodString>;
187
+ query_version: z.ZodOptional<z.ZodString>;
188
+ parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
189
+ contacts_count: z.ZodOptional<z.ZodNumber>;
190
+ contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
191
+ created_at: z.ZodOptional<z.ZodISODateTime>;
192
+ updated_at: z.ZodOptional<z.ZodISODateTime>;
193
+ next_sample_update: z.ZodOptional<z.ZodISODateTime>;
194
+ status: z.ZodOptional<z.ZodObject<{
195
+ query_validation: z.ZodOptional<z.ZodString>;
196
+ error_message: z.ZodOptional<z.ZodString>;
197
+ }, z.core.$catchall<z.ZodUnknown>>>;
198
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
199
+ SENDGRID_API_KEY: z.ZodString;
200
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
201
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
202
+ global: "global";
203
+ eu: "eu";
204
+ }>>;
205
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
206
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
207
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
208
+ SENDGRID_API_KEY: z.ZodString;
209
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
210
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
211
+ global: "global";
212
+ eu: "eu";
213
+ }>>;
214
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
215
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
216
+ }, z.core.$strip>>[] | undefined>], undefined>;
217
+ declare const filterSegmentsByParents: _keystrokehq_core0.Operation<z.ZodObject<{
218
+ parentListIds: z.ZodArray<z.ZodString>;
219
+ }, z.core.$strip>, z.ZodObject<{
220
+ results: z.ZodArray<z.ZodObject<{
221
+ id: z.ZodString;
222
+ name: z.ZodString;
223
+ query_dsl: z.ZodOptional<z.ZodString>;
224
+ query_version: z.ZodOptional<z.ZodString>;
225
+ parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
226
+ contacts_count: z.ZodOptional<z.ZodNumber>;
227
+ contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
228
+ created_at: z.ZodOptional<z.ZodISODateTime>;
229
+ updated_at: z.ZodOptional<z.ZodISODateTime>;
230
+ next_sample_update: z.ZodOptional<z.ZodISODateTime>;
231
+ status: z.ZodOptional<z.ZodObject<{
232
+ query_validation: z.ZodOptional<z.ZodString>;
233
+ error_message: z.ZodOptional<z.ZodString>;
234
+ }, z.core.$catchall<z.ZodUnknown>>>;
235
+ }, z.core.$catchall<z.ZodUnknown>>>;
236
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
237
+ SENDGRID_API_KEY: z.ZodString;
238
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
239
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
240
+ global: "global";
241
+ eu: "eu";
242
+ }>>;
243
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
244
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
245
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
246
+ SENDGRID_API_KEY: z.ZodString;
247
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
248
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
249
+ global: "global";
250
+ eu: "eu";
251
+ }>>;
252
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
253
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
254
+ }, z.core.$strip>>[] | undefined>], undefined>;
255
+ declare const createLegacySegment: _keystrokehq_core0.Operation<z.ZodObject<{
256
+ name: z.ZodString;
257
+ parentListIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
258
+ queryDsl: z.ZodString;
259
+ }, z.core.$strip>, z.ZodObject<{
260
+ id: z.ZodString;
261
+ name: z.ZodString;
262
+ query_dsl: z.ZodOptional<z.ZodString>;
263
+ query_version: z.ZodOptional<z.ZodString>;
264
+ parent_list_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
265
+ contacts_count: z.ZodOptional<z.ZodNumber>;
266
+ contacts_sample_updated_at: z.ZodOptional<z.ZodISODateTime>;
267
+ created_at: z.ZodOptional<z.ZodISODateTime>;
268
+ updated_at: z.ZodOptional<z.ZodISODateTime>;
269
+ next_sample_update: z.ZodOptional<z.ZodISODateTime>;
270
+ status: z.ZodOptional<z.ZodObject<{
271
+ query_validation: z.ZodOptional<z.ZodString>;
272
+ error_message: z.ZodOptional<z.ZodString>;
273
+ }, z.core.$catchall<z.ZodUnknown>>>;
274
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
275
+ SENDGRID_API_KEY: z.ZodString;
276
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
277
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
278
+ global: "global";
279
+ eu: "eu";
280
+ }>>;
281
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
282
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
283
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
284
+ SENDGRID_API_KEY: z.ZodString;
285
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
286
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
287
+ global: "global";
288
+ eu: "eu";
289
+ }>>;
290
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
291
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
292
+ }, z.core.$strip>>[] | undefined>], undefined>;
293
+ declare const deleteLegacySegment: _keystrokehq_core0.Operation<z.ZodObject<{
294
+ segmentId: z.ZodString;
295
+ }, z.core.$strip>, z.ZodObject<{
296
+ success: z.ZodBoolean;
297
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
298
+ SENDGRID_API_KEY: z.ZodString;
299
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
300
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
301
+ global: "global";
302
+ eu: "eu";
303
+ }>>;
304
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
305
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
306
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
307
+ SENDGRID_API_KEY: z.ZodString;
308
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
309
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
310
+ global: "global";
311
+ eu: "eu";
312
+ }>>;
313
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
314
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
315
+ }, z.core.$strip>>[] | undefined>], undefined>;
316
+ declare const removeSegmentWithoutContacts: _keystrokehq_core0.Operation<z.ZodObject<{
317
+ segmentId: z.ZodString;
318
+ }, z.core.$strip>, z.ZodObject<{
319
+ success: z.ZodBoolean;
320
+ }, z.core.$strip>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
321
+ SENDGRID_API_KEY: z.ZodString;
322
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
323
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
324
+ global: "global";
325
+ eu: "eu";
326
+ }>>;
327
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
328
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
329
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
330
+ SENDGRID_API_KEY: z.ZodString;
331
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
332
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
333
+ global: "global";
334
+ eu: "eu";
335
+ }>>;
336
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
337
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
338
+ }, z.core.$strip>>[] | undefined>], undefined>;
339
+ //#endregion
340
+ export { createLegacySegment, createSegment, deleteLegacySegment, deleteSegment, filterSegmentsByParents, getSegment, listSegments, refreshSegment, removeSegmentWithoutContacts, updateSegment };
@@ -0,0 +1,179 @@
1
+ import { n as __exportAll, t as sendgridOperation } from "./factory-BSL0D2L0.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: "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: "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: "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: "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: "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: "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: "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: "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: "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: "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 };