@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,215 @@
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/stats.d.ts
6
+ declare const getGlobalEmailStats: _keystrokehq_core0.Operation<z.ZodObject<{
7
+ startDate: z.ZodISODate;
8
+ endDate: z.ZodOptional<z.ZodISODate>;
9
+ aggregatedBy: z.ZodOptional<z.ZodEnum<{
10
+ day: "day";
11
+ week: "week";
12
+ month: "month";
13
+ }>>;
14
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
15
+ date: z.ZodString;
16
+ stats: z.ZodArray<z.ZodObject<{
17
+ type: z.ZodString;
18
+ name: z.ZodString;
19
+ metrics: z.ZodObject<{
20
+ requests: z.ZodOptional<z.ZodNumber>;
21
+ delivered: z.ZodOptional<z.ZodNumber>;
22
+ opens: z.ZodOptional<z.ZodNumber>;
23
+ unique_opens: z.ZodOptional<z.ZodNumber>;
24
+ clicks: z.ZodOptional<z.ZodNumber>;
25
+ unique_clicks: z.ZodOptional<z.ZodNumber>;
26
+ bounces: z.ZodOptional<z.ZodNumber>;
27
+ bounce_drops: z.ZodOptional<z.ZodNumber>;
28
+ blocks: z.ZodOptional<z.ZodNumber>;
29
+ spam_reports: z.ZodOptional<z.ZodNumber>;
30
+ unsubscribes: z.ZodOptional<z.ZodNumber>;
31
+ unique_unsubscribes: z.ZodOptional<z.ZodNumber>;
32
+ processed: z.ZodOptional<z.ZodNumber>;
33
+ deferred: z.ZodOptional<z.ZodNumber>;
34
+ invalid_emails: z.ZodOptional<z.ZodNumber>;
35
+ }, z.core.$catchall<z.ZodUnknown>>;
36
+ }, z.core.$strip>>;
37
+ }, z.core.$strip>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
38
+ SENDGRID_API_KEY: z.ZodString;
39
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
40
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
41
+ global: "global";
42
+ eu: "eu";
43
+ }>>;
44
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
45
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
46
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
47
+ SENDGRID_API_KEY: z.ZodString;
48
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
49
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
50
+ global: "global";
51
+ eu: "eu";
52
+ }>>;
53
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
54
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
55
+ }, z.core.$strip>>[] | undefined>], undefined>;
56
+ declare const getCategoryStats: _keystrokehq_core0.Operation<z.ZodObject<{
57
+ startDate: z.ZodISODate;
58
+ endDate: z.ZodOptional<z.ZodISODate>;
59
+ aggregatedBy: z.ZodOptional<z.ZodEnum<{
60
+ day: "day";
61
+ week: "week";
62
+ month: "month";
63
+ }>>;
64
+ categories: z.ZodArray<z.ZodString>;
65
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
66
+ date: z.ZodString;
67
+ stats: z.ZodArray<z.ZodObject<{
68
+ type: z.ZodString;
69
+ name: z.ZodString;
70
+ metrics: z.ZodObject<{
71
+ requests: z.ZodOptional<z.ZodNumber>;
72
+ delivered: z.ZodOptional<z.ZodNumber>;
73
+ opens: z.ZodOptional<z.ZodNumber>;
74
+ unique_opens: z.ZodOptional<z.ZodNumber>;
75
+ clicks: z.ZodOptional<z.ZodNumber>;
76
+ unique_clicks: z.ZodOptional<z.ZodNumber>;
77
+ bounces: z.ZodOptional<z.ZodNumber>;
78
+ bounce_drops: z.ZodOptional<z.ZodNumber>;
79
+ blocks: z.ZodOptional<z.ZodNumber>;
80
+ spam_reports: z.ZodOptional<z.ZodNumber>;
81
+ unsubscribes: z.ZodOptional<z.ZodNumber>;
82
+ unique_unsubscribes: z.ZodOptional<z.ZodNumber>;
83
+ processed: z.ZodOptional<z.ZodNumber>;
84
+ deferred: z.ZodOptional<z.ZodNumber>;
85
+ invalid_emails: z.ZodOptional<z.ZodNumber>;
86
+ }, z.core.$catchall<z.ZodUnknown>>;
87
+ }, z.core.$strip>>;
88
+ }, z.core.$strip>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
89
+ SENDGRID_API_KEY: z.ZodString;
90
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
91
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
92
+ global: "global";
93
+ eu: "eu";
94
+ }>>;
95
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
96
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
97
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<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>], undefined>;
107
+ declare const listAutomationStats: _keystrokehq_core0.Operation<z.ZodOptional<z.ZodObject<{
108
+ pageSize: z.ZodOptional<z.ZodNumber>;
109
+ aggregatedBy: z.ZodOptional<z.ZodEnum<{
110
+ day: "day";
111
+ week: "week";
112
+ month: "month";
113
+ total: "total";
114
+ }>>;
115
+ }, z.core.$strip>>, z.ZodObject<{
116
+ results: z.ZodArray<z.ZodUnknown>;
117
+ _metadata: z.ZodOptional<z.ZodUnknown>;
118
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
119
+ SENDGRID_API_KEY: z.ZodString;
120
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
121
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
122
+ global: "global";
123
+ eu: "eu";
124
+ }>>;
125
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
126
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
127
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
128
+ SENDGRID_API_KEY: z.ZodString;
129
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
130
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
131
+ global: "global";
132
+ eu: "eu";
133
+ }>>;
134
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
135
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
136
+ }, z.core.$strip>>[] | undefined>], undefined>;
137
+ declare const getEngagementQualityScores: _keystrokehq_core0.Operation<z.ZodObject<{
138
+ from: z.ZodISODate;
139
+ to: z.ZodISODate;
140
+ }, z.core.$strip>, z.ZodObject<{
141
+ account_id: z.ZodOptional<z.ZodString>;
142
+ date: z.ZodOptional<z.ZodString>;
143
+ metrics: z.ZodOptional<z.ZodUnknown>;
144
+ }, z.core.$catchall<z.ZodUnknown>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
145
+ SENDGRID_API_KEY: z.ZodString;
146
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
147
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
148
+ global: "global";
149
+ eu: "eu";
150
+ }>>;
151
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
152
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
153
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
154
+ SENDGRID_API_KEY: z.ZodString;
155
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
156
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
157
+ global: "global";
158
+ eu: "eu";
159
+ }>>;
160
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
161
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
162
+ }, z.core.$strip>>[] | undefined>], undefined>;
163
+ declare const listMailboxProviderStats: _keystrokehq_core0.Operation<z.ZodObject<{
164
+ startDate: z.ZodISODate;
165
+ endDate: z.ZodOptional<z.ZodISODate>;
166
+ aggregatedBy: z.ZodOptional<z.ZodEnum<{
167
+ day: "day";
168
+ week: "week";
169
+ month: "month";
170
+ }>>;
171
+ mailboxProviders: z.ZodOptional<z.ZodArray<z.ZodString>>;
172
+ }, z.core.$strip>, z.ZodArray<z.ZodObject<{
173
+ date: z.ZodString;
174
+ stats: z.ZodArray<z.ZodObject<{
175
+ type: z.ZodString;
176
+ name: z.ZodString;
177
+ metrics: z.ZodObject<{
178
+ requests: z.ZodOptional<z.ZodNumber>;
179
+ delivered: z.ZodOptional<z.ZodNumber>;
180
+ opens: z.ZodOptional<z.ZodNumber>;
181
+ unique_opens: z.ZodOptional<z.ZodNumber>;
182
+ clicks: z.ZodOptional<z.ZodNumber>;
183
+ unique_clicks: z.ZodOptional<z.ZodNumber>;
184
+ bounces: z.ZodOptional<z.ZodNumber>;
185
+ bounce_drops: z.ZodOptional<z.ZodNumber>;
186
+ blocks: z.ZodOptional<z.ZodNumber>;
187
+ spam_reports: z.ZodOptional<z.ZodNumber>;
188
+ unsubscribes: z.ZodOptional<z.ZodNumber>;
189
+ unique_unsubscribes: z.ZodOptional<z.ZodNumber>;
190
+ processed: z.ZodOptional<z.ZodNumber>;
191
+ deferred: z.ZodOptional<z.ZodNumber>;
192
+ invalid_emails: z.ZodOptional<z.ZodNumber>;
193
+ }, z.core.$catchall<z.ZodUnknown>>;
194
+ }, z.core.$strip>>;
195
+ }, z.core.$strip>>, readonly [_keystrokehq_core0.CredentialSet<"sendgrid", z.ZodObject<{
196
+ SENDGRID_API_KEY: z.ZodString;
197
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
198
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
199
+ global: "global";
200
+ eu: "eu";
201
+ }>>;
202
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
203
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
204
+ }, z.core.$strip>, readonly _keystrokehq_core_credential_set0.CredentialConnection<z.ZodObject<{
205
+ SENDGRID_API_KEY: z.ZodString;
206
+ SENDGRID_SUBUSER: z.ZodOptional<z.ZodString>;
207
+ SENDGRID_ACCOUNT_REGION: z.ZodDefault<z.ZodEnum<{
208
+ global: "global";
209
+ eu: "eu";
210
+ }>>;
211
+ SENDGRID_EVENT_WEBHOOK_PUBLIC_KEY: z.ZodOptional<z.ZodString>;
212
+ SENDGRID_INBOUND_PARSE_TOKEN: z.ZodOptional<z.ZodString>;
213
+ }, z.core.$strip>>[] | undefined>], undefined>;
214
+ //#endregion
215
+ export { getCategoryStats, getEngagementQualityScores, getGlobalEmailStats, listAutomationStats, listMailboxProviderStats };
package/dist/stats.mjs ADDED
@@ -0,0 +1,107 @@
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 { F as sendgridAggregationSchema, I as sendgridAutomationStatsSchema, L as sendgridCategoryStatsSchema, R as sendgridEngagementQualitySchema, z as sendgridStatBucketListSchema } from "./webhooks-CKdsIikb.mjs";
5
+ import { z } from "zod";
6
+
7
+ //#region src/stats.ts
8
+ var stats_exports = /* @__PURE__ */ __exportAll({
9
+ getCategoryStats: () => getCategoryStats,
10
+ getEngagementQualityScores: () => getEngagementQualityScores,
11
+ getGlobalEmailStats: () => getGlobalEmailStats,
12
+ listAutomationStats: () => listAutomationStats,
13
+ listMailboxProviderStats: () => listMailboxProviderStats
14
+ });
15
+ const statsRange = z.object({
16
+ startDate: z.iso.date(),
17
+ endDate: z.iso.date().optional(),
18
+ aggregatedBy: sendgridAggregationSchema.optional()
19
+ });
20
+ function mapStatsQuery(input) {
21
+ return {
22
+ start_date: input.startDate,
23
+ end_date: input.endDate,
24
+ aggregated_by: input.aggregatedBy
25
+ };
26
+ }
27
+ const getGlobalEmailStats = sendgridOperation({
28
+ id: "get_global_email_stats",
29
+ name: "Get Global Email Statistics",
30
+ description: "Return aggregated global email stats over a date range.",
31
+ input: statsRange,
32
+ output: sendgridStatBucketListSchema,
33
+ run: async (input, credentials) => {
34
+ const response = await createSendGridClient(credentials).request("/stats", { query: omitUndefined(mapStatsQuery(input)) });
35
+ return sendgridStatBucketListSchema.parse(response ?? []);
36
+ }
37
+ });
38
+ const getCategoryStats = sendgridOperation({
39
+ id: "get_category_stats",
40
+ name: "Get Category Stats",
41
+ description: "Return email stats broken down by category.",
42
+ input: statsRange.extend({ categories: z.array(z.string().min(1)).min(1).max(10) }),
43
+ output: sendgridCategoryStatsSchema,
44
+ run: async (input, credentials) => {
45
+ const response = await createSendGridClient(credentials).request("/categories/stats", { query: omitUndefined({
46
+ ...mapStatsQuery(input),
47
+ categories: input.categories.join(",")
48
+ }) });
49
+ return sendgridCategoryStatsSchema.parse(response ?? []);
50
+ }
51
+ });
52
+ const listAutomationStats = sendgridOperation({
53
+ id: "list_automation_stats",
54
+ name: "List Automation Stats",
55
+ description: "Return engagement stats for all Automations.",
56
+ input: z.object({
57
+ pageSize: z.number().int().positive().max(100).optional(),
58
+ aggregatedBy: z.enum([
59
+ "total",
60
+ "day",
61
+ "week",
62
+ "month"
63
+ ]).optional()
64
+ }).optional(),
65
+ output: sendgridAutomationStatsSchema,
66
+ run: async (input, credentials) => {
67
+ const response = await createSendGridClient(credentials).request("/marketing/stats/automations", { query: omitUndefined({
68
+ page_size: input?.pageSize,
69
+ aggregated_by: input?.aggregatedBy
70
+ }) });
71
+ return sendgridAutomationStatsSchema.parse(response ?? { results: [] });
72
+ }
73
+ });
74
+ const getEngagementQualityScores = sendgridOperation({
75
+ id: "get_engagement_quality_scores",
76
+ name: "Get Engagement Quality Scores",
77
+ description: "Return engagement-quality (EQ) scores for the account. Plan-gated — requires Pro+.",
78
+ input: z.object({
79
+ from: z.iso.date(),
80
+ to: z.iso.date()
81
+ }),
82
+ output: sendgridEngagementQualitySchema,
83
+ run: async (input, credentials) => {
84
+ const response = await createSendGridClient(credentials).request("/user/eq", { query: {
85
+ from: input.from,
86
+ to: input.to
87
+ } });
88
+ return sendgridEngagementQualitySchema.parse(response);
89
+ }
90
+ });
91
+ const listMailboxProviderStats = sendgridOperation({
92
+ id: "list_mailbox_provider_stats",
93
+ name: "List Mailbox Provider Stats",
94
+ description: "Return email stats broken down by mailbox provider (Gmail, Outlook, etc.).",
95
+ input: statsRange.extend({ mailboxProviders: z.array(z.string().min(1)).optional() }),
96
+ output: sendgridStatBucketListSchema,
97
+ run: async (input, credentials) => {
98
+ const response = await createSendGridClient(credentials).request("/mailbox_providers/stats", { query: omitUndefined({
99
+ ...mapStatsQuery(input),
100
+ mailbox_providers: input.mailboxProviders?.join(",")
101
+ }) });
102
+ return sendgridStatBucketListSchema.parse(response ?? []);
103
+ }
104
+ });
105
+
106
+ //#endregion
107
+ export { getCategoryStats, getEngagementQualityScores, getGlobalEmailStats, listAutomationStats, listMailboxProviderStats, stats_exports as t };