@contractspec/integration.providers-impls 3.8.9 → 3.8.11

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 (147) hide show
  1. package/dist/analytics.js +1 -2
  2. package/dist/calendar.js +1 -2
  3. package/dist/database.js +1 -2
  4. package/dist/email.js +1 -2
  5. package/dist/embedding.js +1 -2
  6. package/dist/health.js +1 -2
  7. package/dist/impls/async-event-queue.js +1 -48
  8. package/dist/impls/composio-fallback-resolver.js +1 -579
  9. package/dist/impls/composio-mcp.js +1 -163
  10. package/dist/impls/composio-proxies.js +1 -310
  11. package/dist/impls/composio-sdk.js +1 -77
  12. package/dist/impls/composio-types.js +1 -53
  13. package/dist/impls/elevenlabs-voice.js +1 -104
  14. package/dist/impls/fal-voice.js +1 -117
  15. package/dist/impls/fathom-meeting-recorder.js +2 -289
  16. package/dist/impls/fathom-meeting-recorder.mapper.js +1 -107
  17. package/dist/impls/fathom-meeting-recorder.utils.js +1 -74
  18. package/dist/impls/fathom-meeting-recorder.webhooks.js +1 -31
  19. package/dist/impls/fireflies-meeting-recorder.js +5 -203
  20. package/dist/impls/fireflies-meeting-recorder.queries.js +4 -14
  21. package/dist/impls/fireflies-meeting-recorder.utils.js +1 -44
  22. package/dist/impls/gcs-storage.js +1 -99
  23. package/dist/impls/gmail-inbound.js +1 -229
  24. package/dist/impls/gmail-outbound.js +25 -137
  25. package/dist/impls/google-calendar.js +1 -193
  26. package/dist/impls/gradium-voice.js +1 -95
  27. package/dist/impls/granola-meeting-recorder.js +3 -514
  28. package/dist/impls/granola-meeting-recorder.mcp.js +1 -280
  29. package/dist/impls/health/base-health-provider.js +1 -617
  30. package/dist/impls/health/hybrid-health-providers.js +1 -1089
  31. package/dist/impls/health/official-health-providers.js +1 -969
  32. package/dist/impls/health/provider-normalizers.js +1 -288
  33. package/dist/impls/health/providers.js +1 -1095
  34. package/dist/impls/health-provider-factory.js +1 -1309
  35. package/dist/impls/index.js +42 -7448
  36. package/dist/impls/jira.js +1 -126
  37. package/dist/impls/linear.js +1 -85
  38. package/dist/impls/messaging-github.js +1 -111
  39. package/dist/impls/messaging-slack.js +1 -81
  40. package/dist/impls/messaging-telegram.js +1 -48
  41. package/dist/impls/messaging-whatsapp-meta.js +1 -53
  42. package/dist/impls/messaging-whatsapp-twilio.js +1 -83
  43. package/dist/impls/mistral-conversational.js +2 -477
  44. package/dist/impls/mistral-conversational.session.js +2 -207
  45. package/dist/impls/mistral-embedding.js +1 -45
  46. package/dist/impls/mistral-llm.js +1 -271
  47. package/dist/impls/mistral-stt.js +1 -168
  48. package/dist/impls/notion.js +1 -162
  49. package/dist/impls/posthog-reader.js +1 -161
  50. package/dist/impls/posthog-utils.js +1 -40
  51. package/dist/impls/posthog.js +1 -324
  52. package/dist/impls/postmark-email.js +1 -62
  53. package/dist/impls/powens-client.js +1 -197
  54. package/dist/impls/powens-openbanking.js +1 -428
  55. package/dist/impls/provider-factory.js +18 -6268
  56. package/dist/impls/qdrant-vector.js +1 -80
  57. package/dist/impls/stripe-payments.js +1 -230
  58. package/dist/impls/supabase-psql.js +1 -152
  59. package/dist/impls/supabase-vector.js +9 -298
  60. package/dist/impls/tldv-meeting-recorder.js +2 -147
  61. package/dist/impls/twilio-sms.js +1 -67
  62. package/dist/index.js +42 -7495
  63. package/dist/llm.js +1 -2
  64. package/dist/meeting-recorder.js +1 -2
  65. package/dist/messaging.js +1 -2
  66. package/dist/node/analytics.js +1 -2
  67. package/dist/node/calendar.js +1 -2
  68. package/dist/node/database.js +1 -2
  69. package/dist/node/email.js +1 -2
  70. package/dist/node/embedding.js +1 -2
  71. package/dist/node/health.js +1 -2
  72. package/dist/node/impls/async-event-queue.js +1 -49
  73. package/dist/node/impls/composio-fallback-resolver.js +1 -580
  74. package/dist/node/impls/composio-mcp.js +1 -164
  75. package/dist/node/impls/composio-proxies.js +1 -311
  76. package/dist/node/impls/composio-sdk.js +1 -78
  77. package/dist/node/impls/composio-types.js +1 -54
  78. package/dist/node/impls/elevenlabs-voice.js +1 -105
  79. package/dist/node/impls/fal-voice.js +1 -118
  80. package/dist/node/impls/fathom-meeting-recorder.js +2 -290
  81. package/dist/node/impls/fathom-meeting-recorder.mapper.js +1 -108
  82. package/dist/node/impls/fathom-meeting-recorder.utils.js +1 -75
  83. package/dist/node/impls/fathom-meeting-recorder.webhooks.js +1 -32
  84. package/dist/node/impls/fireflies-meeting-recorder.js +5 -204
  85. package/dist/node/impls/fireflies-meeting-recorder.queries.js +4 -15
  86. package/dist/node/impls/fireflies-meeting-recorder.utils.js +1 -45
  87. package/dist/node/impls/gcs-storage.js +1 -100
  88. package/dist/node/impls/gmail-inbound.js +1 -230
  89. package/dist/node/impls/gmail-outbound.js +25 -138
  90. package/dist/node/impls/google-calendar.js +1 -194
  91. package/dist/node/impls/gradium-voice.js +1 -96
  92. package/dist/node/impls/granola-meeting-recorder.js +3 -515
  93. package/dist/node/impls/granola-meeting-recorder.mcp.js +1 -281
  94. package/dist/node/impls/health/base-health-provider.js +1 -618
  95. package/dist/node/impls/health/hybrid-health-providers.js +1 -1090
  96. package/dist/node/impls/health/official-health-providers.js +1 -970
  97. package/dist/node/impls/health/provider-normalizers.js +1 -289
  98. package/dist/node/impls/health/providers.js +1 -1096
  99. package/dist/node/impls/health-provider-factory.js +1 -1310
  100. package/dist/node/impls/index.js +42 -7449
  101. package/dist/node/impls/jira.js +1 -127
  102. package/dist/node/impls/linear.js +1 -86
  103. package/dist/node/impls/messaging-github.js +1 -112
  104. package/dist/node/impls/messaging-slack.js +1 -82
  105. package/dist/node/impls/messaging-telegram.js +1 -49
  106. package/dist/node/impls/messaging-whatsapp-meta.js +1 -54
  107. package/dist/node/impls/messaging-whatsapp-twilio.js +1 -84
  108. package/dist/node/impls/mistral-conversational.js +2 -478
  109. package/dist/node/impls/mistral-conversational.session.js +2 -208
  110. package/dist/node/impls/mistral-embedding.js +1 -46
  111. package/dist/node/impls/mistral-llm.js +1 -272
  112. package/dist/node/impls/mistral-stt.js +1 -169
  113. package/dist/node/impls/notion.js +1 -163
  114. package/dist/node/impls/posthog-reader.js +1 -162
  115. package/dist/node/impls/posthog-utils.js +1 -41
  116. package/dist/node/impls/posthog.js +1 -325
  117. package/dist/node/impls/postmark-email.js +1 -63
  118. package/dist/node/impls/powens-client.js +1 -198
  119. package/dist/node/impls/powens-openbanking.js +1 -429
  120. package/dist/node/impls/provider-factory.js +18 -6269
  121. package/dist/node/impls/qdrant-vector.js +1 -81
  122. package/dist/node/impls/stripe-payments.js +1 -231
  123. package/dist/node/impls/supabase-psql.js +1 -153
  124. package/dist/node/impls/supabase-vector.js +9 -299
  125. package/dist/node/impls/tldv-meeting-recorder.js +2 -148
  126. package/dist/node/impls/twilio-sms.js +1 -68
  127. package/dist/node/index.js +42 -7496
  128. package/dist/node/llm.js +1 -2
  129. package/dist/node/meeting-recorder.js +1 -2
  130. package/dist/node/messaging.js +1 -2
  131. package/dist/node/openbanking.js +1 -2
  132. package/dist/node/payments.js +1 -2
  133. package/dist/node/project-management.js +1 -2
  134. package/dist/node/secrets/provider.js +1 -14
  135. package/dist/node/sms.js +1 -2
  136. package/dist/node/storage.js +1 -2
  137. package/dist/node/vector-store.js +1 -2
  138. package/dist/node/voice.js +1 -2
  139. package/dist/openbanking.js +1 -2
  140. package/dist/payments.js +1 -2
  141. package/dist/project-management.js +1 -2
  142. package/dist/secrets/provider.js +1 -13
  143. package/dist/sms.js +1 -2
  144. package/dist/storage.js +1 -2
  145. package/dist/vector-store.js +1 -2
  146. package/dist/voice.js +1 -2
  147. package/package.json +16 -16
@@ -1,162 +1,2 @@
1
1
  // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/impls/posthog-reader.ts
5
- class PosthogAnalyticsReader {
6
- projectId;
7
- client;
8
- constructor(options) {
9
- this.projectId = options.projectId;
10
- this.client = options.client;
11
- }
12
- async queryHogQL(input) {
13
- const projectId = resolveProjectId(undefined, this.projectId);
14
- const response = await this.client.request({
15
- method: "POST",
16
- path: `/api/projects/${projectId}/query`,
17
- body: {
18
- query: {
19
- kind: "HogQLQuery",
20
- query: input.query,
21
- values: input.values
22
- }
23
- }
24
- });
25
- return response.data;
26
- }
27
- async getEvents(input) {
28
- const projectId = resolveProjectId(input.projectId, this.projectId);
29
- const response = await this.client.request({
30
- method: "GET",
31
- path: `/api/projects/${projectId}/events/`,
32
- query: {
33
- event: input.event ?? resolveSingleEvent(input.events),
34
- events: resolveEventList(input.events),
35
- distinct_id: input.distinctId,
36
- order_by: input.orderBy,
37
- limit: input.limit,
38
- offset: input.offset,
39
- properties: input.properties ? JSON.stringify(input.properties) : undefined,
40
- ...buildEventDateQuery(input.dateRange)
41
- }
42
- });
43
- return response.data;
44
- }
45
- async getPersons(input) {
46
- const projectId = resolveProjectId(input.projectId, this.projectId);
47
- const response = await this.client.request({
48
- method: "GET",
49
- path: `/api/projects/${projectId}/persons/`,
50
- query: {
51
- cohort_id: input.cohortId,
52
- search: input.search,
53
- limit: input.limit,
54
- offset: input.offset,
55
- properties: input.properties ? JSON.stringify(input.properties) : undefined
56
- }
57
- });
58
- return response.data;
59
- }
60
- async getInsights(input) {
61
- const projectId = resolveProjectId(input.projectId, this.projectId);
62
- const response = await this.client.request({
63
- method: "GET",
64
- path: `/api/projects/${projectId}/insights/`,
65
- query: {
66
- insight: input.insightType,
67
- limit: input.limit,
68
- offset: input.offset
69
- }
70
- });
71
- return response.data;
72
- }
73
- async getInsightResult(input) {
74
- const projectId = resolveProjectId(input.projectId, this.projectId);
75
- const response = await this.client.request({
76
- method: "GET",
77
- path: `/api/projects/${projectId}/insights/${input.insightId}/`
78
- });
79
- return response.data;
80
- }
81
- async getCohorts(input) {
82
- const projectId = resolveProjectId(input.projectId, this.projectId);
83
- const response = await this.client.request({
84
- method: "GET",
85
- path: `/api/projects/${projectId}/cohorts/`,
86
- query: {
87
- limit: input.limit,
88
- offset: input.offset
89
- }
90
- });
91
- return response.data;
92
- }
93
- async getFeatureFlags(input) {
94
- const projectId = resolveProjectId(input.projectId, this.projectId);
95
- const response = await this.client.request({
96
- method: "GET",
97
- path: `/api/projects/${projectId}/feature_flags/`,
98
- query: {
99
- active: input.active,
100
- limit: input.limit,
101
- offset: input.offset
102
- }
103
- });
104
- return response.data;
105
- }
106
- async getAnnotations(input) {
107
- const projectId = resolveProjectId(input.projectId, this.projectId);
108
- const response = await this.client.request({
109
- method: "GET",
110
- path: `/api/projects/${projectId}/annotations/`,
111
- query: {
112
- limit: input.limit,
113
- offset: input.offset,
114
- ...buildAnnotationDateQuery(input.dateRange)
115
- }
116
- });
117
- return response.data;
118
- }
119
- }
120
- function resolveProjectId(inputProjectId, defaultProjectId) {
121
- const projectId = inputProjectId ?? defaultProjectId;
122
- if (!projectId) {
123
- throw new Error("PostHog projectId is required for API reads.");
124
- }
125
- return projectId;
126
- }
127
- function resolveSingleEvent(events) {
128
- if (!events || events.length !== 1)
129
- return;
130
- return events[0];
131
- }
132
- function resolveEventList(events) {
133
- if (!events || events.length <= 1)
134
- return;
135
- return events.join(",");
136
- }
137
- function buildEventDateQuery(range) {
138
- const after = formatDate(range?.from);
139
- const before = formatDate(range?.to);
140
- return {
141
- after,
142
- before,
143
- timezone: range?.timezone
144
- };
145
- }
146
- function buildAnnotationDateQuery(range) {
147
- const dateFrom = formatDate(range?.from);
148
- const dateTo = formatDate(range?.to);
149
- return {
150
- date_from: dateFrom,
151
- date_to: dateTo,
152
- timezone: range?.timezone
153
- };
154
- }
155
- function formatDate(value) {
156
- if (!value)
157
- return;
158
- return typeof value === "string" ? value : value.toISOString();
159
- }
160
- export {
161
- PosthogAnalyticsReader
162
- };
2
+ var p=import.meta.require;class o{projectId;client;constructor(e){this.projectId=e.projectId,this.client=e.client}async queryHogQL(e){let t=n(void 0,this.projectId);return(await this.client.request({method:"POST",path:`/api/projects/${t}/query`,body:{query:{kind:"HogQLQuery",query:e.query,values:e.values}}})).data}async getEvents(e){let t=n(e.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${t}/events/`,query:{event:e.event??i(e.events),events:a(e.events),distinct_id:e.distinctId,order_by:e.orderBy,limit:e.limit,offset:e.offset,properties:e.properties?JSON.stringify(e.properties):void 0,...c(e.dateRange)}})).data}async getPersons(e){let t=n(e.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${t}/persons/`,query:{cohort_id:e.cohortId,search:e.search,limit:e.limit,offset:e.offset,properties:e.properties?JSON.stringify(e.properties):void 0}})).data}async getInsights(e){let t=n(e.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${t}/insights/`,query:{insight:e.insightType,limit:e.limit,offset:e.offset}})).data}async getInsightResult(e){let t=n(e.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${t}/insights/${e.insightId}/`})).data}async getCohorts(e){let t=n(e.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${t}/cohorts/`,query:{limit:e.limit,offset:e.offset}})).data}async getFeatureFlags(e){let t=n(e.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${t}/feature_flags/`,query:{active:e.active,limit:e.limit,offset:e.offset}})).data}async getAnnotations(e){let t=n(e.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${t}/annotations/`,query:{limit:e.limit,offset:e.offset,...d(e.dateRange)}})).data}}function n(e,t){let s=e??t;if(!s)throw Error("PostHog projectId is required for API reads.");return s}function i(e){if(!e||e.length!==1)return;return e[0]}function a(e){if(!e||e.length<=1)return;return e.join(",")}function c(e){let t=r(e?.from),s=r(e?.to);return{after:t,before:s,timezone:e?.timezone}}function d(e){let t=r(e?.from),s=r(e?.to);return{date_from:t,date_to:s,timezone:e?.timezone}}function r(e){if(!e)return;return typeof e==="string"?e:e.toISOString()}export{o as PosthogAnalyticsReader};
@@ -1,41 +1,2 @@
1
1
  // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/impls/posthog-utils.ts
5
- function normalizeHost(host) {
6
- return host.replace(/\/$/, "");
7
- }
8
- function buildUrl(host, path, query) {
9
- if (/^https?:\/\//.test(path)) {
10
- return appendQuery(path, query);
11
- }
12
- const normalizedPath = path.replace(/^\/+/, "");
13
- return appendQuery(`${host}/${normalizedPath}`, query);
14
- }
15
- function appendQuery(url, query) {
16
- if (!query)
17
- return url;
18
- const params = new URLSearchParams;
19
- Object.entries(query).forEach(([key, value]) => {
20
- if (value === undefined)
21
- return;
22
- params.set(key, String(value));
23
- });
24
- const suffix = params.toString();
25
- return suffix ? `${url}?${suffix}` : url;
26
- }
27
- function parseJson(value) {
28
- if (!value)
29
- return {};
30
- try {
31
- return JSON.parse(value);
32
- } catch {
33
- return value;
34
- }
35
- }
36
- export {
37
- parseJson,
38
- normalizeHost,
39
- buildUrl,
40
- appendQuery
41
- };
2
+ var c=import.meta.require;function f(n){return n.replace(/\/$/,"")}function g(n,r,t){if(/^https?:\/\//.test(r))return s(r,t);let e=r.replace(/^\/+/,"");return s(`${n}/${e}`,t)}function s(n,r){if(!r)return n;let t=new URLSearchParams;Object.entries(r).forEach(([o,i])=>{if(i===void 0)return;t.set(o,String(i))});let e=t.toString();return e?`${n}?${e}`:n}function u(n){if(!n)return{};try{return JSON.parse(n)}catch{return n}}export{u as parseJson,f as normalizeHost,g as buildUrl,s as appendQuery};
@@ -1,325 +1,2 @@
1
1
  // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/impls/posthog-reader.ts
5
- class PosthogAnalyticsReader {
6
- projectId;
7
- client;
8
- constructor(options) {
9
- this.projectId = options.projectId;
10
- this.client = options.client;
11
- }
12
- async queryHogQL(input) {
13
- const projectId = resolveProjectId(undefined, this.projectId);
14
- const response = await this.client.request({
15
- method: "POST",
16
- path: `/api/projects/${projectId}/query`,
17
- body: {
18
- query: {
19
- kind: "HogQLQuery",
20
- query: input.query,
21
- values: input.values
22
- }
23
- }
24
- });
25
- return response.data;
26
- }
27
- async getEvents(input) {
28
- const projectId = resolveProjectId(input.projectId, this.projectId);
29
- const response = await this.client.request({
30
- method: "GET",
31
- path: `/api/projects/${projectId}/events/`,
32
- query: {
33
- event: input.event ?? resolveSingleEvent(input.events),
34
- events: resolveEventList(input.events),
35
- distinct_id: input.distinctId,
36
- order_by: input.orderBy,
37
- limit: input.limit,
38
- offset: input.offset,
39
- properties: input.properties ? JSON.stringify(input.properties) : undefined,
40
- ...buildEventDateQuery(input.dateRange)
41
- }
42
- });
43
- return response.data;
44
- }
45
- async getPersons(input) {
46
- const projectId = resolveProjectId(input.projectId, this.projectId);
47
- const response = await this.client.request({
48
- method: "GET",
49
- path: `/api/projects/${projectId}/persons/`,
50
- query: {
51
- cohort_id: input.cohortId,
52
- search: input.search,
53
- limit: input.limit,
54
- offset: input.offset,
55
- properties: input.properties ? JSON.stringify(input.properties) : undefined
56
- }
57
- });
58
- return response.data;
59
- }
60
- async getInsights(input) {
61
- const projectId = resolveProjectId(input.projectId, this.projectId);
62
- const response = await this.client.request({
63
- method: "GET",
64
- path: `/api/projects/${projectId}/insights/`,
65
- query: {
66
- insight: input.insightType,
67
- limit: input.limit,
68
- offset: input.offset
69
- }
70
- });
71
- return response.data;
72
- }
73
- async getInsightResult(input) {
74
- const projectId = resolveProjectId(input.projectId, this.projectId);
75
- const response = await this.client.request({
76
- method: "GET",
77
- path: `/api/projects/${projectId}/insights/${input.insightId}/`
78
- });
79
- return response.data;
80
- }
81
- async getCohorts(input) {
82
- const projectId = resolveProjectId(input.projectId, this.projectId);
83
- const response = await this.client.request({
84
- method: "GET",
85
- path: `/api/projects/${projectId}/cohorts/`,
86
- query: {
87
- limit: input.limit,
88
- offset: input.offset
89
- }
90
- });
91
- return response.data;
92
- }
93
- async getFeatureFlags(input) {
94
- const projectId = resolveProjectId(input.projectId, this.projectId);
95
- const response = await this.client.request({
96
- method: "GET",
97
- path: `/api/projects/${projectId}/feature_flags/`,
98
- query: {
99
- active: input.active,
100
- limit: input.limit,
101
- offset: input.offset
102
- }
103
- });
104
- return response.data;
105
- }
106
- async getAnnotations(input) {
107
- const projectId = resolveProjectId(input.projectId, this.projectId);
108
- const response = await this.client.request({
109
- method: "GET",
110
- path: `/api/projects/${projectId}/annotations/`,
111
- query: {
112
- limit: input.limit,
113
- offset: input.offset,
114
- ...buildAnnotationDateQuery(input.dateRange)
115
- }
116
- });
117
- return response.data;
118
- }
119
- }
120
- function resolveProjectId(inputProjectId, defaultProjectId) {
121
- const projectId = inputProjectId ?? defaultProjectId;
122
- if (!projectId) {
123
- throw new Error("PostHog projectId is required for API reads.");
124
- }
125
- return projectId;
126
- }
127
- function resolveSingleEvent(events) {
128
- if (!events || events.length !== 1)
129
- return;
130
- return events[0];
131
- }
132
- function resolveEventList(events) {
133
- if (!events || events.length <= 1)
134
- return;
135
- return events.join(",");
136
- }
137
- function buildEventDateQuery(range) {
138
- const after = formatDate(range?.from);
139
- const before = formatDate(range?.to);
140
- return {
141
- after,
142
- before,
143
- timezone: range?.timezone
144
- };
145
- }
146
- function buildAnnotationDateQuery(range) {
147
- const dateFrom = formatDate(range?.from);
148
- const dateTo = formatDate(range?.to);
149
- return {
150
- date_from: dateFrom,
151
- date_to: dateTo,
152
- timezone: range?.timezone
153
- };
154
- }
155
- function formatDate(value) {
156
- if (!value)
157
- return;
158
- return typeof value === "string" ? value : value.toISOString();
159
- }
160
-
161
- // src/impls/posthog-utils.ts
162
- function normalizeHost(host) {
163
- return host.replace(/\/$/, "");
164
- }
165
- function buildUrl(host, path, query) {
166
- if (/^https?:\/\//.test(path)) {
167
- return appendQuery(path, query);
168
- }
169
- const normalizedPath = path.replace(/^\/+/, "");
170
- return appendQuery(`${host}/${normalizedPath}`, query);
171
- }
172
- function appendQuery(url, query) {
173
- if (!query)
174
- return url;
175
- const params = new URLSearchParams;
176
- Object.entries(query).forEach(([key, value]) => {
177
- if (value === undefined)
178
- return;
179
- params.set(key, String(value));
180
- });
181
- const suffix = params.toString();
182
- return suffix ? `${url}?${suffix}` : url;
183
- }
184
- function parseJson(value) {
185
- if (!value)
186
- return {};
187
- try {
188
- return JSON.parse(value);
189
- } catch {
190
- return value;
191
- }
192
- }
193
-
194
- // src/impls/posthog.ts
195
- import { PostHog } from "posthog-node";
196
- var DEFAULT_POSTHOG_HOST = "https://app.posthog.com";
197
-
198
- class PosthogAnalyticsProvider {
199
- host;
200
- projectId;
201
- projectApiKey;
202
- personalApiKey;
203
- mcpUrl;
204
- fetchFn;
205
- client;
206
- reader;
207
- constructor(options) {
208
- this.host = normalizeHost(options.host ?? DEFAULT_POSTHOG_HOST);
209
- this.projectId = options.projectId;
210
- this.projectApiKey = options.projectApiKey;
211
- this.personalApiKey = options.personalApiKey;
212
- this.mcpUrl = options.mcpUrl;
213
- this.fetchFn = options.fetch ?? fetch;
214
- this.client = options.client ?? (options.projectApiKey ? new PostHog(options.projectApiKey, {
215
- host: this.host,
216
- requestTimeout: options.requestTimeoutMs ?? 1e4
217
- }) : undefined);
218
- this.reader = new PosthogAnalyticsReader({
219
- projectId: this.projectId,
220
- client: { request: this.request.bind(this) }
221
- });
222
- }
223
- async capture(event) {
224
- if (!this.client) {
225
- throw new Error("PostHog projectApiKey is required for capture.");
226
- }
227
- await this.client.capture({
228
- distinctId: event.distinctId,
229
- event: event.event,
230
- properties: event.properties,
231
- timestamp: event.timestamp,
232
- groups: event.groups
233
- });
234
- }
235
- async identify(input) {
236
- if (!this.client) {
237
- throw new Error("PostHog projectApiKey is required for identify.");
238
- }
239
- await this.client.identify({
240
- distinctId: input.distinctId,
241
- properties: {
242
- ...input.properties ? { $set: input.properties } : {},
243
- ...input.setOnce ? { $set_once: input.setOnce } : {}
244
- }
245
- });
246
- }
247
- async queryHogQL(input) {
248
- return this.reader.queryHogQL(input);
249
- }
250
- async getEvents(input) {
251
- return this.reader.getEvents(input);
252
- }
253
- async getPersons(input) {
254
- return this.reader.getPersons(input);
255
- }
256
- async getInsights(input) {
257
- return this.reader.getInsights(input);
258
- }
259
- async getInsightResult(input) {
260
- return this.reader.getInsightResult(input);
261
- }
262
- async getCohorts(input) {
263
- return this.reader.getCohorts(input);
264
- }
265
- async getFeatureFlags(input) {
266
- return this.reader.getFeatureFlags(input);
267
- }
268
- async getAnnotations(input) {
269
- return this.reader.getAnnotations(input);
270
- }
271
- async request(request) {
272
- if (!this.personalApiKey) {
273
- throw new Error("PostHog personalApiKey is required for API requests.");
274
- }
275
- const url = buildUrl(this.host, request.path, request.query);
276
- const response = await this.fetchFn(url, {
277
- method: request.method,
278
- headers: {
279
- Authorization: `Bearer ${this.personalApiKey}`,
280
- "Content-Type": "application/json",
281
- ...request.headers ?? {}
282
- },
283
- body: request.body ? JSON.stringify(request.body) : undefined
284
- });
285
- const text = await response.text();
286
- const data = parseJson(text);
287
- return {
288
- status: response.status,
289
- data,
290
- headers: Object.fromEntries(response.headers.entries())
291
- };
292
- }
293
- async callMcpTool(call) {
294
- if (!this.mcpUrl) {
295
- throw new Error("PostHog MCP URL is not configured.");
296
- }
297
- const response = await this.fetchFn(this.mcpUrl, {
298
- method: "POST",
299
- headers: {
300
- "Content-Type": "application/json"
301
- },
302
- body: JSON.stringify({
303
- jsonrpc: "2.0",
304
- id: 1,
305
- method: "tools/call",
306
- params: {
307
- name: call.name,
308
- arguments: call.arguments ?? {}
309
- }
310
- })
311
- });
312
- if (!response.ok) {
313
- const body = await response.text();
314
- throw new Error(`PostHog MCP error (${response.status}): ${body}`);
315
- }
316
- const result = await response.json();
317
- if (result.error) {
318
- throw new Error(result.error.message ?? "PostHog MCP error");
319
- }
320
- return result.result ?? null;
321
- }
322
- }
323
- export {
324
- PosthogAnalyticsProvider
325
- };
2
+ var P=import.meta.require;class a{projectId;client;constructor(t){this.projectId=t.projectId,this.client=t.client}async queryHogQL(t){let e=r(void 0,this.projectId);return(await this.client.request({method:"POST",path:`/api/projects/${e}/query`,body:{query:{kind:"HogQLQuery",query:t.query,values:t.values}}})).data}async getEvents(t){let e=r(t.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${e}/events/`,query:{event:t.event??y(t.events),events:g(t.events),distinct_id:t.distinctId,order_by:t.orderBy,limit:t.limit,offset:t.offset,properties:t.properties?JSON.stringify(t.properties):void 0,...h(t.dateRange)}})).data}async getPersons(t){let e=r(t.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${e}/persons/`,query:{cohort_id:t.cohortId,search:t.search,limit:t.limit,offset:t.offset,properties:t.properties?JSON.stringify(t.properties):void 0}})).data}async getInsights(t){let e=r(t.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${e}/insights/`,query:{insight:t.insightType,limit:t.limit,offset:t.offset}})).data}async getInsightResult(t){let e=r(t.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${e}/insights/${t.insightId}/`})).data}async getCohorts(t){let e=r(t.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${e}/cohorts/`,query:{limit:t.limit,offset:t.offset}})).data}async getFeatureFlags(t){let e=r(t.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${e}/feature_flags/`,query:{active:t.active,limit:t.limit,offset:t.offset}})).data}async getAnnotations(t){let e=r(t.projectId,this.projectId);return(await this.client.request({method:"GET",path:`/api/projects/${e}/annotations/`,query:{limit:t.limit,offset:t.offset,...f(t.dateRange)}})).data}}function r(t,e){let s=t??e;if(!s)throw Error("PostHog projectId is required for API reads.");return s}function y(t){if(!t||t.length!==1)return;return t[0]}function g(t){if(!t||t.length<=1)return;return t.join(",")}function h(t){let e=o(t?.from),s=o(t?.to);return{after:e,before:s,timezone:t?.timezone}}function f(t){let e=o(t?.from),s=o(t?.to);return{date_from:e,date_to:s,timezone:t?.timezone}}function o(t){if(!t)return;return typeof t==="string"?t:t.toISOString()}function d(t){return t.replace(/\/$/,"")}function l(t,e,s){if(/^https?:\/\//.test(e))return p(e,s);let n=e.replace(/^\/+/,"");return p(`${t}/${n}`,s)}function p(t,e){if(!e)return t;let s=new URLSearchParams;Object.entries(e).forEach(([i,c])=>{if(c===void 0)return;s.set(i,String(c))});let n=s.toString();return n?`${t}?${n}`:t}function u(t){if(!t)return{};try{return JSON.parse(t)}catch{return t}}import{PostHog as I}from"posthog-node";var m="https://app.posthog.com";class A{host;projectId;projectApiKey;personalApiKey;mcpUrl;fetchFn;client;reader;constructor(t){this.host=d(t.host??m),this.projectId=t.projectId,this.projectApiKey=t.projectApiKey,this.personalApiKey=t.personalApiKey,this.mcpUrl=t.mcpUrl,this.fetchFn=t.fetch??fetch,this.client=t.client??(t.projectApiKey?new I(t.projectApiKey,{host:this.host,requestTimeout:t.requestTimeoutMs??1e4}):void 0),this.reader=new a({projectId:this.projectId,client:{request:this.request.bind(this)}})}async capture(t){if(!this.client)throw Error("PostHog projectApiKey is required for capture.");await this.client.capture({distinctId:t.distinctId,event:t.event,properties:t.properties,timestamp:t.timestamp,groups:t.groups})}async identify(t){if(!this.client)throw Error("PostHog projectApiKey is required for identify.");await this.client.identify({distinctId:t.distinctId,properties:{...t.properties?{$set:t.properties}:{},...t.setOnce?{$set_once:t.setOnce}:{}}})}async queryHogQL(t){return this.reader.queryHogQL(t)}async getEvents(t){return this.reader.getEvents(t)}async getPersons(t){return this.reader.getPersons(t)}async getInsights(t){return this.reader.getInsights(t)}async getInsightResult(t){return this.reader.getInsightResult(t)}async getCohorts(t){return this.reader.getCohorts(t)}async getFeatureFlags(t){return this.reader.getFeatureFlags(t)}async getAnnotations(t){return this.reader.getAnnotations(t)}async request(t){if(!this.personalApiKey)throw Error("PostHog personalApiKey is required for API requests.");let e=l(this.host,t.path,t.query),s=await this.fetchFn(e,{method:t.method,headers:{Authorization:`Bearer ${this.personalApiKey}`,"Content-Type":"application/json",...t.headers??{}},body:t.body?JSON.stringify(t.body):void 0}),n=await s.text(),i=u(n);return{status:s.status,data:i,headers:Object.fromEntries(s.headers.entries())}}async callMcpTool(t){if(!this.mcpUrl)throw Error("PostHog MCP URL is not configured.");let e=await this.fetchFn(this.mcpUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"tools/call",params:{name:t.name,arguments:t.arguments??{}}})});if(!e.ok){let n=await e.text();throw Error(`PostHog MCP error (${e.status}): ${n}`)}let s=await e.json();if(s.error)throw Error(s.error.message??"PostHog MCP error");return s.result??null}}export{A as PosthogAnalyticsProvider};
@@ -1,63 +1,2 @@
1
1
  // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/impls/postmark-email.ts
5
- import { ServerClient } from "postmark";
6
-
7
- class PostmarkEmailProvider {
8
- client;
9
- defaultFromEmail;
10
- messageStream;
11
- constructor(options) {
12
- this.client = options.client ?? new ServerClient(options.serverToken, {
13
- useHttps: true
14
- });
15
- this.defaultFromEmail = options.defaultFromEmail;
16
- this.messageStream = options.messageStream;
17
- }
18
- async sendEmail(message) {
19
- const request = {
20
- From: formatAddress(message.from) ?? this.defaultFromEmail,
21
- To: message.to.map((addr) => formatAddress(addr)).join(", "),
22
- Cc: message.cc?.map((addr) => formatAddress(addr)).join(", ") || undefined,
23
- Bcc: message.bcc?.map((addr) => formatAddress(addr)).join(", ") || undefined,
24
- ReplyTo: message.replyTo ? formatAddress(message.replyTo) : undefined,
25
- Subject: message.subject,
26
- TextBody: message.textBody,
27
- HtmlBody: message.htmlBody,
28
- Headers: message.headers ? Object.entries(message.headers).map(([name, value]) => ({
29
- Name: name,
30
- Value: value
31
- })) : undefined,
32
- MessageStream: this.messageStream,
33
- Attachments: buildAttachments(message)
34
- };
35
- const response = await this.client.sendEmail(request);
36
- return {
37
- id: response.MessageID,
38
- providerMessageId: response.MessageID,
39
- queuedAt: new Date(response.SubmittedAt ?? new Date().toISOString())
40
- };
41
- }
42
- }
43
- function formatAddress(address) {
44
- if (address.name) {
45
- return `"${address.name}" <${address.email}>`;
46
- }
47
- return address.email;
48
- }
49
- function buildAttachments(message) {
50
- if (!message.attachments?.length)
51
- return;
52
- return message.attachments.filter((attachment) => attachment.data).map((attachment) => ({
53
- Name: attachment.filename,
54
- Content: Buffer.from(attachment.data ?? new Uint8Array).toString("base64"),
55
- ContentType: attachment.contentType,
56
- ContentID: null,
57
- ContentLength: attachment.sizeBytes,
58
- Disposition: "attachment"
59
- }));
60
- }
61
- export {
62
- PostmarkEmailProvider
63
- };
2
+ var s=import.meta.require;import{ServerClient as o}from"postmark";class m{client;defaultFromEmail;messageStream;constructor(e){this.client=e.client??new o(e.serverToken,{useHttps:!0}),this.defaultFromEmail=e.defaultFromEmail,this.messageStream=e.messageStream}async sendEmail(e){let t={From:n(e.from)??this.defaultFromEmail,To:e.to.map((r)=>n(r)).join(", "),Cc:e.cc?.map((r)=>n(r)).join(", ")||void 0,Bcc:e.bcc?.map((r)=>n(r)).join(", ")||void 0,ReplyTo:e.replyTo?n(e.replyTo):void 0,Subject:e.subject,TextBody:e.textBody,HtmlBody:e.htmlBody,Headers:e.headers?Object.entries(e.headers).map(([r,a])=>({Name:r,Value:a})):void 0,MessageStream:this.messageStream,Attachments:l(e)},i=await this.client.sendEmail(t);return{id:i.MessageID,providerMessageId:i.MessageID,queuedAt:new Date(i.SubmittedAt??new Date().toISOString())}}}function n(e){if(e.name)return`"${e.name}" <${e.email}>`;return e.email}function l(e){if(!e.attachments?.length)return;return e.attachments.filter((t)=>t.data).map((t)=>({Name:t.filename,Content:Buffer.from(t.data??new Uint8Array).toString("base64"),ContentType:t.contentType,ContentID:null,ContentLength:t.sizeBytes,Disposition:"attachment"}))}export{m as PostmarkEmailProvider};