@contractspec/integration.providers-impls 1.56.1 → 1.58.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 (238) hide show
  1. package/README.md +115 -1
  2. package/dist/analytics.d.ts +2 -0
  3. package/dist/analytics.d.ts.map +1 -0
  4. package/dist/analytics.js +3 -0
  5. package/dist/calendar.d.ts +1 -7
  6. package/dist/calendar.d.ts.map +1 -1
  7. package/dist/calendar.js +3 -3
  8. package/dist/database.d.ts +2 -0
  9. package/dist/database.d.ts.map +1 -0
  10. package/dist/database.js +3 -0
  11. package/dist/email.d.ts +1 -7
  12. package/dist/email.d.ts.map +1 -1
  13. package/dist/email.js +3 -3
  14. package/dist/embedding.d.ts +1 -7
  15. package/dist/embedding.d.ts.map +1 -1
  16. package/dist/embedding.js +3 -3
  17. package/dist/impls/elevenlabs-voice.d.ts +14 -18
  18. package/dist/impls/elevenlabs-voice.d.ts.map +1 -1
  19. package/dist/impls/elevenlabs-voice.js +98 -88
  20. package/dist/impls/fal-voice.d.ts +25 -0
  21. package/dist/impls/fal-voice.d.ts.map +1 -0
  22. package/dist/impls/fal-voice.js +113 -0
  23. package/dist/impls/fathom-meeting-recorder.d.ts +38 -0
  24. package/dist/impls/fathom-meeting-recorder.d.ts.map +1 -0
  25. package/dist/impls/fathom-meeting-recorder.js +288 -0
  26. package/dist/impls/fathom-meeting-recorder.mapper.d.ts +5 -0
  27. package/dist/impls/fathom-meeting-recorder.mapper.d.ts.map +1 -0
  28. package/dist/impls/fathom-meeting-recorder.mapper.js +106 -0
  29. package/dist/impls/fathom-meeting-recorder.types.d.ts +20 -0
  30. package/dist/impls/fathom-meeting-recorder.types.d.ts.map +1 -0
  31. package/dist/impls/fathom-meeting-recorder.types.js +1 -0
  32. package/dist/impls/fathom-meeting-recorder.utils.d.ts +11 -0
  33. package/dist/impls/fathom-meeting-recorder.utils.d.ts.map +1 -0
  34. package/dist/impls/fathom-meeting-recorder.utils.js +73 -0
  35. package/dist/impls/fathom-meeting-recorder.webhooks.d.ts +4 -0
  36. package/dist/impls/fathom-meeting-recorder.webhooks.d.ts.map +1 -0
  37. package/dist/impls/fathom-meeting-recorder.webhooks.js +30 -0
  38. package/dist/impls/fireflies-meeting-recorder.d.ts +24 -0
  39. package/dist/impls/fireflies-meeting-recorder.d.ts.map +1 -0
  40. package/dist/impls/fireflies-meeting-recorder.js +275 -0
  41. package/dist/impls/fireflies-meeting-recorder.queries.d.ts +4 -0
  42. package/dist/impls/fireflies-meeting-recorder.queries.d.ts.map +1 -0
  43. package/dist/impls/fireflies-meeting-recorder.queries.js +86 -0
  44. package/dist/impls/fireflies-meeting-recorder.types.d.ts +32 -0
  45. package/dist/impls/fireflies-meeting-recorder.types.d.ts.map +1 -0
  46. package/dist/impls/fireflies-meeting-recorder.types.js +1 -0
  47. package/dist/impls/fireflies-meeting-recorder.utils.d.ts +5 -0
  48. package/dist/impls/fireflies-meeting-recorder.utils.d.ts.map +1 -0
  49. package/dist/impls/fireflies-meeting-recorder.utils.js +43 -0
  50. package/dist/impls/gcs-storage.d.ts +18 -22
  51. package/dist/impls/gcs-storage.d.ts.map +1 -1
  52. package/dist/impls/gcs-storage.js +92 -84
  53. package/dist/impls/gmail-inbound.d.ts +20 -24
  54. package/dist/impls/gmail-inbound.d.ts.map +1 -1
  55. package/dist/impls/gmail-inbound.js +212 -185
  56. package/dist/impls/gmail-outbound.d.ts +12 -16
  57. package/dist/impls/gmail-outbound.d.ts.map +1 -1
  58. package/dist/impls/gmail-outbound.js +126 -92
  59. package/dist/impls/google-calendar.d.ts +17 -21
  60. package/dist/impls/google-calendar.d.ts.map +1 -1
  61. package/dist/impls/google-calendar.js +182 -145
  62. package/dist/impls/gradium-voice.d.ts +24 -0
  63. package/dist/impls/gradium-voice.d.ts.map +1 -0
  64. package/dist/impls/gradium-voice.js +91 -0
  65. package/dist/impls/granola-meeting-recorder.d.ts +34 -0
  66. package/dist/impls/granola-meeting-recorder.d.ts.map +1 -0
  67. package/dist/impls/granola-meeting-recorder.js +513 -0
  68. package/dist/impls/granola-meeting-recorder.mcp.d.ts +25 -0
  69. package/dist/impls/granola-meeting-recorder.mcp.d.ts.map +1 -0
  70. package/dist/impls/granola-meeting-recorder.mcp.js +279 -0
  71. package/dist/impls/granola-meeting-recorder.types.d.ts +61 -0
  72. package/dist/impls/granola-meeting-recorder.types.d.ts.map +1 -0
  73. package/dist/impls/granola-meeting-recorder.types.js +1 -0
  74. package/dist/impls/index.d.ts +28 -15
  75. package/dist/impls/index.d.ts.map +1 -0
  76. package/dist/impls/index.js +4659 -16
  77. package/dist/impls/jira.d.ts +21 -0
  78. package/dist/impls/jira.d.ts.map +1 -0
  79. package/dist/impls/jira.js +125 -0
  80. package/dist/impls/linear.d.ts +20 -0
  81. package/dist/impls/linear.d.ts.map +1 -0
  82. package/dist/impls/linear.js +84 -0
  83. package/dist/impls/mistral-embedding.d.ts +17 -21
  84. package/dist/impls/mistral-embedding.d.ts.map +1 -1
  85. package/dist/impls/mistral-embedding.js +41 -39
  86. package/dist/impls/mistral-llm.d.ts +25 -29
  87. package/dist/impls/mistral-llm.d.ts.map +1 -1
  88. package/dist/impls/mistral-llm.js +266 -244
  89. package/dist/impls/notion.d.ts +23 -0
  90. package/dist/impls/notion.d.ts.map +1 -0
  91. package/dist/impls/notion.js +161 -0
  92. package/dist/impls/posthog-reader.d.ts +22 -0
  93. package/dist/impls/posthog-reader.d.ts.map +1 -0
  94. package/dist/impls/posthog-reader.js +160 -0
  95. package/dist/impls/posthog-utils.d.ts +5 -0
  96. package/dist/impls/posthog-utils.d.ts.map +1 -0
  97. package/dist/impls/posthog-utils.js +39 -0
  98. package/dist/impls/posthog.d.ts +36 -0
  99. package/dist/impls/posthog.d.ts.map +1 -0
  100. package/dist/impls/posthog.js +323 -0
  101. package/dist/impls/postmark-email.d.ts +13 -17
  102. package/dist/impls/postmark-email.d.ts.map +1 -1
  103. package/dist/impls/postmark-email.js +55 -50
  104. package/dist/impls/powens-client.d.ts +111 -114
  105. package/dist/impls/powens-client.d.ts.map +1 -1
  106. package/dist/impls/powens-client.js +194 -170
  107. package/dist/impls/powens-openbanking.d.ts +22 -26
  108. package/dist/impls/powens-openbanking.d.ts.map +1 -1
  109. package/dist/impls/powens-openbanking.js +425 -217
  110. package/dist/impls/provider-factory.d.ts +29 -25
  111. package/dist/impls/provider-factory.d.ts.map +1 -1
  112. package/dist/impls/provider-factory.js +4074 -136
  113. package/dist/impls/qdrant-vector.d.ts +18 -22
  114. package/dist/impls/qdrant-vector.d.ts.map +1 -1
  115. package/dist/impls/qdrant-vector.js +76 -69
  116. package/dist/impls/stripe-payments.d.ts +22 -26
  117. package/dist/impls/stripe-payments.d.ts.map +1 -1
  118. package/dist/impls/stripe-payments.js +219 -193
  119. package/dist/impls/supabase-psql.d.ts +24 -0
  120. package/dist/impls/supabase-psql.d.ts.map +1 -0
  121. package/dist/impls/supabase-psql.js +151 -0
  122. package/dist/impls/supabase-vector.d.ts +32 -0
  123. package/dist/impls/supabase-vector.d.ts.map +1 -0
  124. package/dist/impls/supabase-vector.js +324 -0
  125. package/dist/impls/tldv-meeting-recorder.d.ts +21 -0
  126. package/dist/impls/tldv-meeting-recorder.d.ts.map +1 -0
  127. package/dist/impls/tldv-meeting-recorder.js +146 -0
  128. package/dist/impls/twilio-sms.d.ts +14 -17
  129. package/dist/impls/twilio-sms.d.ts.map +1 -1
  130. package/dist/impls/twilio-sms.js +62 -55
  131. package/dist/index.d.ts +15 -43
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +4700 -69
  134. package/dist/llm.d.ts +1 -7
  135. package/dist/llm.d.ts.map +1 -1
  136. package/dist/llm.js +3 -3
  137. package/dist/meeting-recorder.d.ts +2 -0
  138. package/dist/meeting-recorder.d.ts.map +1 -0
  139. package/dist/meeting-recorder.js +3 -0
  140. package/dist/node/analytics.js +2 -0
  141. package/dist/node/calendar.js +2 -0
  142. package/dist/node/database.js +2 -0
  143. package/dist/node/email.js +2 -0
  144. package/dist/node/embedding.js +2 -0
  145. package/dist/node/impls/elevenlabs-voice.js +102 -0
  146. package/dist/node/impls/fal-voice.js +112 -0
  147. package/dist/node/impls/fathom-meeting-recorder.js +287 -0
  148. package/dist/node/impls/fathom-meeting-recorder.mapper.js +105 -0
  149. package/dist/node/impls/fathom-meeting-recorder.types.js +0 -0
  150. package/dist/node/impls/fathom-meeting-recorder.utils.js +72 -0
  151. package/dist/node/impls/fathom-meeting-recorder.webhooks.js +29 -0
  152. package/dist/node/impls/fireflies-meeting-recorder.js +274 -0
  153. package/dist/node/impls/fireflies-meeting-recorder.queries.js +85 -0
  154. package/dist/node/impls/fireflies-meeting-recorder.types.js +0 -0
  155. package/dist/node/impls/fireflies-meeting-recorder.utils.js +42 -0
  156. package/dist/node/impls/gcs-storage.js +97 -0
  157. package/dist/node/impls/gmail-inbound.js +227 -0
  158. package/dist/node/impls/gmail-outbound.js +139 -0
  159. package/dist/node/impls/google-calendar.js +191 -0
  160. package/dist/node/impls/gradium-voice.js +90 -0
  161. package/dist/node/impls/granola-meeting-recorder.js +512 -0
  162. package/dist/node/impls/granola-meeting-recorder.mcp.js +278 -0
  163. package/dist/node/impls/granola-meeting-recorder.types.js +0 -0
  164. package/dist/node/impls/index.js +4658 -0
  165. package/dist/node/impls/jira.js +124 -0
  166. package/dist/node/impls/linear.js +83 -0
  167. package/dist/node/impls/mistral-embedding.js +43 -0
  168. package/dist/node/impls/mistral-llm.js +269 -0
  169. package/dist/node/impls/notion.js +160 -0
  170. package/dist/node/impls/posthog-reader.js +159 -0
  171. package/dist/node/impls/posthog-utils.js +38 -0
  172. package/dist/node/impls/posthog.js +322 -0
  173. package/dist/node/impls/postmark-email.js +60 -0
  174. package/dist/node/impls/powens-client.js +195 -0
  175. package/dist/node/impls/powens-openbanking.js +426 -0
  176. package/dist/node/impls/provider-factory.js +4080 -0
  177. package/dist/node/impls/qdrant-vector.js +78 -0
  178. package/dist/node/impls/stripe-payments.js +228 -0
  179. package/dist/node/impls/supabase-psql.js +150 -0
  180. package/dist/node/impls/supabase-vector.js +323 -0
  181. package/dist/node/impls/tldv-meeting-recorder.js +145 -0
  182. package/dist/node/impls/twilio-sms.js +65 -0
  183. package/dist/node/index.js +4699 -0
  184. package/dist/node/llm.js +2 -0
  185. package/dist/node/meeting-recorder.js +2 -0
  186. package/dist/node/openbanking.js +2 -0
  187. package/dist/node/payments.js +2 -0
  188. package/dist/node/project-management.js +2 -0
  189. package/dist/node/runtime.js +0 -0
  190. package/dist/node/secrets/provider.js +11 -0
  191. package/dist/node/sms.js +2 -0
  192. package/dist/node/storage.js +2 -0
  193. package/dist/node/vector-store.js +2 -0
  194. package/dist/node/voice.js +2 -0
  195. package/dist/openbanking.d.ts +1 -7
  196. package/dist/openbanking.d.ts.map +1 -1
  197. package/dist/openbanking.js +3 -3
  198. package/dist/payments.d.ts +1 -7
  199. package/dist/payments.d.ts.map +1 -1
  200. package/dist/payments.js +3 -3
  201. package/dist/project-management.d.ts +2 -0
  202. package/dist/project-management.d.ts.map +1 -0
  203. package/dist/project-management.js +3 -0
  204. package/dist/runtime.d.ts +2 -2
  205. package/dist/runtime.d.ts.map +1 -0
  206. package/dist/runtime.js +1 -0
  207. package/dist/secrets/provider.d.ts +3 -2
  208. package/dist/secrets/provider.d.ts.map +1 -0
  209. package/dist/secrets/provider.js +12 -3
  210. package/dist/sms.d.ts +1 -7
  211. package/dist/sms.d.ts.map +1 -1
  212. package/dist/sms.js +3 -3
  213. package/dist/storage.d.ts +1 -7
  214. package/dist/storage.d.ts.map +1 -1
  215. package/dist/storage.js +3 -3
  216. package/dist/vector-store.d.ts +1 -7
  217. package/dist/vector-store.d.ts.map +1 -1
  218. package/dist/vector-store.js +3 -3
  219. package/dist/voice.d.ts +1 -7
  220. package/dist/voice.d.ts.map +1 -1
  221. package/dist/voice.js +3 -3
  222. package/package.json +419 -76
  223. package/dist/_virtual/rolldown_runtime.js +0 -36
  224. package/dist/impls/elevenlabs-voice.js.map +0 -1
  225. package/dist/impls/gcs-storage.js.map +0 -1
  226. package/dist/impls/gmail-inbound.js.map +0 -1
  227. package/dist/impls/gmail-outbound.js.map +0 -1
  228. package/dist/impls/google-calendar.js.map +0 -1
  229. package/dist/impls/mistral-embedding.js.map +0 -1
  230. package/dist/impls/mistral-llm.js.map +0 -1
  231. package/dist/impls/postmark-email.js.map +0 -1
  232. package/dist/impls/powens-client.js.map +0 -1
  233. package/dist/impls/powens-openbanking.js.map +0 -1
  234. package/dist/impls/provider-factory.js.map +0 -1
  235. package/dist/impls/qdrant-vector.js.map +0 -1
  236. package/dist/impls/stripe-payments.js.map +0 -1
  237. package/dist/impls/twilio-sms.js.map +0 -1
  238. package/dist/index.js.map +0 -1
@@ -0,0 +1,323 @@
1
+ // @bun
2
+ // src/impls/posthog-reader.ts
3
+ class PosthogAnalyticsReader {
4
+ projectId;
5
+ client;
6
+ constructor(options) {
7
+ this.projectId = options.projectId;
8
+ this.client = options.client;
9
+ }
10
+ async queryHogQL(input) {
11
+ const projectId = resolveProjectId(undefined, this.projectId);
12
+ const response = await this.client.request({
13
+ method: "POST",
14
+ path: `/api/projects/${projectId}/query`,
15
+ body: {
16
+ query: {
17
+ kind: "HogQLQuery",
18
+ query: input.query,
19
+ values: input.values
20
+ }
21
+ }
22
+ });
23
+ return response.data;
24
+ }
25
+ async getEvents(input) {
26
+ const projectId = resolveProjectId(input.projectId, this.projectId);
27
+ const response = await this.client.request({
28
+ method: "GET",
29
+ path: `/api/projects/${projectId}/events/`,
30
+ query: {
31
+ event: input.event ?? resolveSingleEvent(input.events),
32
+ events: resolveEventList(input.events),
33
+ distinct_id: input.distinctId,
34
+ order_by: input.orderBy,
35
+ limit: input.limit,
36
+ offset: input.offset,
37
+ properties: input.properties ? JSON.stringify(input.properties) : undefined,
38
+ ...buildEventDateQuery(input.dateRange)
39
+ }
40
+ });
41
+ return response.data;
42
+ }
43
+ async getPersons(input) {
44
+ const projectId = resolveProjectId(input.projectId, this.projectId);
45
+ const response = await this.client.request({
46
+ method: "GET",
47
+ path: `/api/projects/${projectId}/persons/`,
48
+ query: {
49
+ cohort_id: input.cohortId,
50
+ search: input.search,
51
+ limit: input.limit,
52
+ offset: input.offset,
53
+ properties: input.properties ? JSON.stringify(input.properties) : undefined
54
+ }
55
+ });
56
+ return response.data;
57
+ }
58
+ async getInsights(input) {
59
+ const projectId = resolveProjectId(input.projectId, this.projectId);
60
+ const response = await this.client.request({
61
+ method: "GET",
62
+ path: `/api/projects/${projectId}/insights/`,
63
+ query: {
64
+ insight: input.insightType,
65
+ limit: input.limit,
66
+ offset: input.offset
67
+ }
68
+ });
69
+ return response.data;
70
+ }
71
+ async getInsightResult(input) {
72
+ const projectId = resolveProjectId(input.projectId, this.projectId);
73
+ const response = await this.client.request({
74
+ method: "GET",
75
+ path: `/api/projects/${projectId}/insights/${input.insightId}/`
76
+ });
77
+ return response.data;
78
+ }
79
+ async getCohorts(input) {
80
+ const projectId = resolveProjectId(input.projectId, this.projectId);
81
+ const response = await this.client.request({
82
+ method: "GET",
83
+ path: `/api/projects/${projectId}/cohorts/`,
84
+ query: {
85
+ limit: input.limit,
86
+ offset: input.offset
87
+ }
88
+ });
89
+ return response.data;
90
+ }
91
+ async getFeatureFlags(input) {
92
+ const projectId = resolveProjectId(input.projectId, this.projectId);
93
+ const response = await this.client.request({
94
+ method: "GET",
95
+ path: `/api/projects/${projectId}/feature_flags/`,
96
+ query: {
97
+ active: input.active,
98
+ limit: input.limit,
99
+ offset: input.offset
100
+ }
101
+ });
102
+ return response.data;
103
+ }
104
+ async getAnnotations(input) {
105
+ const projectId = resolveProjectId(input.projectId, this.projectId);
106
+ const response = await this.client.request({
107
+ method: "GET",
108
+ path: `/api/projects/${projectId}/annotations/`,
109
+ query: {
110
+ limit: input.limit,
111
+ offset: input.offset,
112
+ ...buildAnnotationDateQuery(input.dateRange)
113
+ }
114
+ });
115
+ return response.data;
116
+ }
117
+ }
118
+ function resolveProjectId(inputProjectId, defaultProjectId) {
119
+ const projectId = inputProjectId ?? defaultProjectId;
120
+ if (!projectId) {
121
+ throw new Error("PostHog projectId is required for API reads.");
122
+ }
123
+ return projectId;
124
+ }
125
+ function resolveSingleEvent(events) {
126
+ if (!events || events.length !== 1)
127
+ return;
128
+ return events[0];
129
+ }
130
+ function resolveEventList(events) {
131
+ if (!events || events.length <= 1)
132
+ return;
133
+ return events.join(",");
134
+ }
135
+ function buildEventDateQuery(range) {
136
+ const after = formatDate(range?.from);
137
+ const before = formatDate(range?.to);
138
+ return {
139
+ after,
140
+ before,
141
+ timezone: range?.timezone
142
+ };
143
+ }
144
+ function buildAnnotationDateQuery(range) {
145
+ const dateFrom = formatDate(range?.from);
146
+ const dateTo = formatDate(range?.to);
147
+ return {
148
+ date_from: dateFrom,
149
+ date_to: dateTo,
150
+ timezone: range?.timezone
151
+ };
152
+ }
153
+ function formatDate(value) {
154
+ if (!value)
155
+ return;
156
+ return typeof value === "string" ? value : value.toISOString();
157
+ }
158
+
159
+ // src/impls/posthog-utils.ts
160
+ function normalizeHost(host) {
161
+ return host.replace(/\/$/, "");
162
+ }
163
+ function buildUrl(host, path, query) {
164
+ if (/^https?:\/\//.test(path)) {
165
+ return appendQuery(path, query);
166
+ }
167
+ const normalizedPath = path.replace(/^\/+/, "");
168
+ return appendQuery(`${host}/${normalizedPath}`, query);
169
+ }
170
+ function appendQuery(url, query) {
171
+ if (!query)
172
+ return url;
173
+ const params = new URLSearchParams;
174
+ Object.entries(query).forEach(([key, value]) => {
175
+ if (value === undefined)
176
+ return;
177
+ params.set(key, String(value));
178
+ });
179
+ const suffix = params.toString();
180
+ return suffix ? `${url}?${suffix}` : url;
181
+ }
182
+ function parseJson(value) {
183
+ if (!value)
184
+ return {};
185
+ try {
186
+ return JSON.parse(value);
187
+ } catch {
188
+ return value;
189
+ }
190
+ }
191
+
192
+ // src/impls/posthog.ts
193
+ import { PostHog } from "posthog-node";
194
+ var DEFAULT_POSTHOG_HOST = "https://app.posthog.com";
195
+
196
+ class PosthogAnalyticsProvider {
197
+ host;
198
+ projectId;
199
+ projectApiKey;
200
+ personalApiKey;
201
+ mcpUrl;
202
+ fetchFn;
203
+ client;
204
+ reader;
205
+ constructor(options) {
206
+ this.host = normalizeHost(options.host ?? DEFAULT_POSTHOG_HOST);
207
+ this.projectId = options.projectId;
208
+ this.projectApiKey = options.projectApiKey;
209
+ this.personalApiKey = options.personalApiKey;
210
+ this.mcpUrl = options.mcpUrl;
211
+ this.fetchFn = options.fetch ?? fetch;
212
+ this.client = options.client ?? (options.projectApiKey ? new PostHog(options.projectApiKey, {
213
+ host: this.host,
214
+ requestTimeout: options.requestTimeoutMs ?? 1e4
215
+ }) : undefined);
216
+ this.reader = new PosthogAnalyticsReader({
217
+ projectId: this.projectId,
218
+ client: { request: this.request.bind(this) }
219
+ });
220
+ }
221
+ async capture(event) {
222
+ if (!this.client) {
223
+ throw new Error("PostHog projectApiKey is required for capture.");
224
+ }
225
+ await this.client.capture({
226
+ distinctId: event.distinctId,
227
+ event: event.event,
228
+ properties: event.properties,
229
+ timestamp: event.timestamp,
230
+ groups: event.groups
231
+ });
232
+ }
233
+ async identify(input) {
234
+ if (!this.client) {
235
+ throw new Error("PostHog projectApiKey is required for identify.");
236
+ }
237
+ await this.client.identify({
238
+ distinctId: input.distinctId,
239
+ properties: {
240
+ ...input.properties ? { $set: input.properties } : {},
241
+ ...input.setOnce ? { $set_once: input.setOnce } : {}
242
+ }
243
+ });
244
+ }
245
+ async queryHogQL(input) {
246
+ return this.reader.queryHogQL(input);
247
+ }
248
+ async getEvents(input) {
249
+ return this.reader.getEvents(input);
250
+ }
251
+ async getPersons(input) {
252
+ return this.reader.getPersons(input);
253
+ }
254
+ async getInsights(input) {
255
+ return this.reader.getInsights(input);
256
+ }
257
+ async getInsightResult(input) {
258
+ return this.reader.getInsightResult(input);
259
+ }
260
+ async getCohorts(input) {
261
+ return this.reader.getCohorts(input);
262
+ }
263
+ async getFeatureFlags(input) {
264
+ return this.reader.getFeatureFlags(input);
265
+ }
266
+ async getAnnotations(input) {
267
+ return this.reader.getAnnotations(input);
268
+ }
269
+ async request(request) {
270
+ if (!this.personalApiKey) {
271
+ throw new Error("PostHog personalApiKey is required for API requests.");
272
+ }
273
+ const url = buildUrl(this.host, request.path, request.query);
274
+ const response = await this.fetchFn(url, {
275
+ method: request.method,
276
+ headers: {
277
+ Authorization: `Bearer ${this.personalApiKey}`,
278
+ "Content-Type": "application/json",
279
+ ...request.headers ?? {}
280
+ },
281
+ body: request.body ? JSON.stringify(request.body) : undefined
282
+ });
283
+ const text = await response.text();
284
+ const data = parseJson(text);
285
+ return {
286
+ status: response.status,
287
+ data,
288
+ headers: Object.fromEntries(response.headers.entries())
289
+ };
290
+ }
291
+ async callMcpTool(call) {
292
+ if (!this.mcpUrl) {
293
+ throw new Error("PostHog MCP URL is not configured.");
294
+ }
295
+ const response = await this.fetchFn(this.mcpUrl, {
296
+ method: "POST",
297
+ headers: {
298
+ "Content-Type": "application/json"
299
+ },
300
+ body: JSON.stringify({
301
+ jsonrpc: "2.0",
302
+ id: 1,
303
+ method: "tools/call",
304
+ params: {
305
+ name: call.name,
306
+ arguments: call.arguments ?? {}
307
+ }
308
+ })
309
+ });
310
+ if (!response.ok) {
311
+ const body = await response.text();
312
+ throw new Error(`PostHog MCP error (${response.status}): ${body}`);
313
+ }
314
+ const result = await response.json();
315
+ if (result.error) {
316
+ throw new Error(result.error.message ?? "PostHog MCP error");
317
+ }
318
+ return result.result ?? null;
319
+ }
320
+ }
321
+ export {
322
+ PosthogAnalyticsProvider
323
+ };
@@ -1,20 +1,16 @@
1
- import { email_d_exports } from "../email.js";
2
- import { ServerClient } from "postmark";
3
-
4
- //#region src/impls/postmark-email.d.ts
5
- interface PostmarkEmailProviderOptions {
6
- serverToken: string;
7
- defaultFromEmail?: string;
8
- messageStream?: string;
9
- client?: ServerClient;
1
+ import { ServerClient } from 'postmark';
2
+ import type { EmailOutboundMessage, EmailOutboundProvider, EmailOutboundResult } from '../email';
3
+ export interface PostmarkEmailProviderOptions {
4
+ serverToken: string;
5
+ defaultFromEmail?: string;
6
+ messageStream?: string;
7
+ client?: ServerClient;
10
8
  }
11
- declare class PostmarkEmailProvider implements email_d_exports.EmailOutboundProvider {
12
- private readonly client;
13
- private readonly defaultFromEmail?;
14
- private readonly messageStream?;
15
- constructor(options: PostmarkEmailProviderOptions);
16
- sendEmail(message: email_d_exports.EmailOutboundMessage): Promise<email_d_exports.EmailOutboundResult>;
9
+ export declare class PostmarkEmailProvider implements EmailOutboundProvider {
10
+ private readonly client;
11
+ private readonly defaultFromEmail?;
12
+ private readonly messageStream?;
13
+ constructor(options: PostmarkEmailProviderOptions);
14
+ sendEmail(message: EmailOutboundMessage): Promise<EmailOutboundResult>;
17
15
  }
18
- //#endregion
19
- export { PostmarkEmailProvider, PostmarkEmailProviderOptions };
20
16
  //# sourceMappingURL=postmark-email.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postmark-email.d.ts","names":[],"sources":["../../src/impls/postmark-email.ts"],"sourcesContent":[],"mappings":";;;;UAQiB,4BAAA;;EAAA,gBAAA,CAAA,EAAA,MAAA;EAOJ,aAAA,CAAA,EAAA,MAAA;EAKU,MAAA,CAAA,EARZ,YAQY;;AAUmC,cAf7C,qBAAA,YAAiC,eAAA,CAAA,qBAeY,CAAA;EAAR,iBAAA,MAAA;EAfJ,iBAAA,gBAAA;EAAqB,iBAAA,aAAA;uBAK5C;qBAUI,eAAA,CAAA,uBAAuB,QAAQ,eAAA,CAAA"}
1
+ {"version":3,"file":"postmark-email.d.ts","sourceRoot":"","sources":["../../src/impls/postmark-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiC,MAAM,UAAU,CAAC;AAEvE,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,qBAAa,qBAAsB,YAAW,qBAAqB;IACjE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAS;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAS;gBAE5B,OAAO,EAAE,4BAA4B;IAU3C,SAAS,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA6B7E"}
@@ -1,56 +1,61 @@
1
+ // @bun
2
+ // src/impls/postmark-email.ts
1
3
  import { ServerClient } from "postmark";
2
4
 
3
- //#region src/impls/postmark-email.ts
4
- var PostmarkEmailProvider = class {
5
- client;
6
- defaultFromEmail;
7
- messageStream;
8
- constructor(options) {
9
- this.client = options.client ?? new ServerClient(options.serverToken, { useHttps: true });
10
- this.defaultFromEmail = options.defaultFromEmail;
11
- this.messageStream = options.messageStream;
12
- }
13
- async sendEmail(message) {
14
- const request = {
15
- From: formatAddress(message.from) ?? this.defaultFromEmail,
16
- To: message.to.map((addr) => formatAddress(addr)).join(", "),
17
- Cc: message.cc?.map((addr) => formatAddress(addr)).join(", ") || void 0,
18
- Bcc: message.bcc?.map((addr) => formatAddress(addr)).join(", ") || void 0,
19
- ReplyTo: message.replyTo ? formatAddress(message.replyTo) : void 0,
20
- Subject: message.subject,
21
- TextBody: message.textBody,
22
- HtmlBody: message.htmlBody,
23
- Headers: message.headers ? Object.entries(message.headers).map(([name, value]) => ({
24
- Name: name,
25
- Value: value
26
- })) : void 0,
27
- MessageStream: this.messageStream,
28
- Attachments: buildAttachments(message)
29
- };
30
- const response = await this.client.sendEmail(request);
31
- return {
32
- id: response.MessageID,
33
- providerMessageId: response.MessageID,
34
- queuedAt: new Date(response.SubmittedAt ?? (/* @__PURE__ */ new Date()).toISOString())
35
- };
36
- }
37
- };
5
+ class PostmarkEmailProvider {
6
+ client;
7
+ defaultFromEmail;
8
+ messageStream;
9
+ constructor(options) {
10
+ this.client = options.client ?? new ServerClient(options.serverToken, {
11
+ useHttps: true
12
+ });
13
+ this.defaultFromEmail = options.defaultFromEmail;
14
+ this.messageStream = options.messageStream;
15
+ }
16
+ async sendEmail(message) {
17
+ const request = {
18
+ From: formatAddress(message.from) ?? this.defaultFromEmail,
19
+ To: message.to.map((addr) => formatAddress(addr)).join(", "),
20
+ Cc: message.cc?.map((addr) => formatAddress(addr)).join(", ") || undefined,
21
+ Bcc: message.bcc?.map((addr) => formatAddress(addr)).join(", ") || undefined,
22
+ ReplyTo: message.replyTo ? formatAddress(message.replyTo) : undefined,
23
+ Subject: message.subject,
24
+ TextBody: message.textBody,
25
+ HtmlBody: message.htmlBody,
26
+ Headers: message.headers ? Object.entries(message.headers).map(([name, value]) => ({
27
+ Name: name,
28
+ Value: value
29
+ })) : undefined,
30
+ MessageStream: this.messageStream,
31
+ Attachments: buildAttachments(message)
32
+ };
33
+ const response = await this.client.sendEmail(request);
34
+ return {
35
+ id: response.MessageID,
36
+ providerMessageId: response.MessageID,
37
+ queuedAt: new Date(response.SubmittedAt ?? new Date().toISOString())
38
+ };
39
+ }
40
+ }
38
41
  function formatAddress(address) {
39
- if (address.name) return `"${address.name}" <${address.email}>`;
40
- return address.email;
42
+ if (address.name) {
43
+ return `"${address.name}" <${address.email}>`;
44
+ }
45
+ return address.email;
41
46
  }
42
47
  function buildAttachments(message) {
43
- if (!message.attachments?.length) return void 0;
44
- return message.attachments.filter((attachment) => attachment.data).map((attachment) => ({
45
- Name: attachment.filename,
46
- Content: Buffer.from(attachment.data ?? new Uint8Array()).toString("base64"),
47
- ContentType: attachment.contentType,
48
- ContentID: null,
49
- ContentLength: attachment.sizeBytes,
50
- Disposition: "attachment"
51
- }));
48
+ if (!message.attachments?.length)
49
+ return;
50
+ return message.attachments.filter((attachment) => attachment.data).map((attachment) => ({
51
+ Name: attachment.filename,
52
+ Content: Buffer.from(attachment.data ?? new Uint8Array).toString("base64"),
53
+ ContentType: attachment.contentType,
54
+ ContentID: null,
55
+ ContentLength: attachment.sizeBytes,
56
+ Disposition: "attachment"
57
+ }));
52
58
  }
53
-
54
- //#endregion
55
- export { PostmarkEmailProvider };
56
- //# sourceMappingURL=postmark-email.js.map
59
+ export {
60
+ PostmarkEmailProvider
61
+ };