@contractspec/integration.providers-impls 1.57.0 → 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.
- package/dist/analytics.d.ts +1 -8
- package/dist/analytics.d.ts.map +1 -1
- package/dist/analytics.js +3 -3
- package/dist/calendar.d.ts +1 -8
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +3 -3
- package/dist/database.d.ts +1 -8
- package/dist/database.d.ts.map +1 -1
- package/dist/database.js +3 -3
- package/dist/email.d.ts +1 -8
- package/dist/email.d.ts.map +1 -1
- package/dist/email.js +3 -3
- package/dist/embedding.d.ts +1 -8
- package/dist/embedding.d.ts.map +1 -1
- package/dist/embedding.js +3 -3
- package/dist/impls/elevenlabs-voice.d.ts +14 -18
- package/dist/impls/elevenlabs-voice.d.ts.map +1 -1
- package/dist/impls/elevenlabs-voice.js +98 -88
- package/dist/impls/fal-voice.d.ts +22 -26
- package/dist/impls/fal-voice.d.ts.map +1 -1
- package/dist/impls/fal-voice.js +103 -78
- package/dist/impls/fathom-meeting-recorder.d.ts +35 -39
- package/dist/impls/fathom-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.js +285 -142
- package/dist/impls/fathom-meeting-recorder.mapper.d.ts +4 -8
- package/dist/impls/fathom-meeting-recorder.mapper.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.mapper.js +102 -38
- package/dist/impls/fathom-meeting-recorder.types.d.ts +16 -20
- package/dist/impls/fathom-meeting-recorder.types.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.types.js +1 -0
- package/dist/impls/fathom-meeting-recorder.utils.d.ts +10 -14
- package/dist/impls/fathom-meeting-recorder.utils.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.utils.js +58 -41
- package/dist/impls/fathom-meeting-recorder.webhooks.d.ts +3 -7
- package/dist/impls/fathom-meeting-recorder.webhooks.d.ts.map +1 -1
- package/dist/impls/fathom-meeting-recorder.webhooks.js +25 -20
- package/dist/impls/fireflies-meeting-recorder.d.ts +21 -25
- package/dist/impls/fireflies-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.js +272 -149
- package/dist/impls/fireflies-meeting-recorder.queries.d.ts +3 -6
- package/dist/impls/fireflies-meeting-recorder.queries.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.queries.js +10 -8
- package/dist/impls/fireflies-meeting-recorder.types.d.ts +26 -29
- package/dist/impls/fireflies-meeting-recorder.types.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.types.js +1 -0
- package/dist/impls/fireflies-meeting-recorder.utils.d.ts +4 -7
- package/dist/impls/fireflies-meeting-recorder.utils.d.ts.map +1 -1
- package/dist/impls/fireflies-meeting-recorder.utils.js +34 -27
- package/dist/impls/gcs-storage.d.ts +18 -22
- package/dist/impls/gcs-storage.d.ts.map +1 -1
- package/dist/impls/gcs-storage.js +92 -84
- package/dist/impls/gmail-inbound.d.ts +20 -24
- package/dist/impls/gmail-inbound.d.ts.map +1 -1
- package/dist/impls/gmail-inbound.js +212 -185
- package/dist/impls/gmail-outbound.d.ts +12 -16
- package/dist/impls/gmail-outbound.d.ts.map +1 -1
- package/dist/impls/gmail-outbound.js +126 -92
- package/dist/impls/google-calendar.d.ts +17 -21
- package/dist/impls/google-calendar.d.ts.map +1 -1
- package/dist/impls/google-calendar.js +182 -145
- package/dist/impls/gradium-voice.d.ts +20 -22
- package/dist/impls/gradium-voice.d.ts.map +1 -1
- package/dist/impls/gradium-voice.js +85 -74
- package/dist/impls/granola-meeting-recorder.d.ts +31 -24
- package/dist/impls/granola-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/granola-meeting-recorder.js +511 -143
- package/dist/impls/granola-meeting-recorder.mcp.d.ts +25 -0
- package/dist/impls/granola-meeting-recorder.mcp.d.ts.map +1 -0
- package/dist/impls/granola-meeting-recorder.mcp.js +279 -0
- package/dist/impls/granola-meeting-recorder.types.d.ts +60 -49
- package/dist/impls/granola-meeting-recorder.types.d.ts.map +1 -1
- package/dist/impls/granola-meeting-recorder.types.js +1 -0
- package/dist/impls/index.d.ts +28 -28
- package/dist/impls/index.d.ts.map +1 -0
- package/dist/impls/index.js +4659 -29
- package/dist/impls/jira.d.ts +18 -22
- package/dist/impls/jira.d.ts.map +1 -1
- package/dist/impls/jira.js +112 -101
- package/dist/impls/linear.d.ts +17 -21
- package/dist/impls/linear.d.ts.map +1 -1
- package/dist/impls/linear.js +78 -69
- package/dist/impls/mistral-embedding.d.ts +17 -21
- package/dist/impls/mistral-embedding.d.ts.map +1 -1
- package/dist/impls/mistral-embedding.js +41 -39
- package/dist/impls/mistral-llm.d.ts +25 -29
- package/dist/impls/mistral-llm.d.ts.map +1 -1
- package/dist/impls/mistral-llm.js +266 -244
- package/dist/impls/notion.d.ts +20 -24
- package/dist/impls/notion.d.ts.map +1 -1
- package/dist/impls/notion.js +145 -110
- package/dist/impls/posthog-reader.d.ts +18 -22
- package/dist/impls/posthog-reader.d.ts.map +1 -1
- package/dist/impls/posthog-reader.js +148 -129
- package/dist/impls/posthog-utils.d.ts +4 -7
- package/dist/impls/posthog-utils.d.ts.map +1 -1
- package/dist/impls/posthog-utils.js +31 -22
- package/dist/impls/posthog.d.ts +33 -37
- package/dist/impls/posthog.d.ts.map +1 -1
- package/dist/impls/posthog.js +320 -119
- package/dist/impls/postmark-email.d.ts +13 -17
- package/dist/impls/postmark-email.d.ts.map +1 -1
- package/dist/impls/postmark-email.js +55 -50
- package/dist/impls/powens-client.d.ts +111 -114
- package/dist/impls/powens-client.d.ts.map +1 -1
- package/dist/impls/powens-client.js +194 -170
- package/dist/impls/powens-openbanking.d.ts +22 -26
- package/dist/impls/powens-openbanking.d.ts.map +1 -1
- package/dist/impls/powens-openbanking.js +425 -217
- package/dist/impls/provider-factory.d.ts +29 -33
- package/dist/impls/provider-factory.d.ts.map +1 -1
- package/dist/impls/provider-factory.js +4072 -275
- package/dist/impls/qdrant-vector.d.ts +18 -22
- package/dist/impls/qdrant-vector.d.ts.map +1 -1
- package/dist/impls/qdrant-vector.js +76 -69
- package/dist/impls/stripe-payments.d.ts +22 -26
- package/dist/impls/stripe-payments.d.ts.map +1 -1
- package/dist/impls/stripe-payments.js +219 -193
- package/dist/impls/supabase-psql.d.ts +21 -25
- package/dist/impls/supabase-psql.d.ts.map +1 -1
- package/dist/impls/supabase-psql.js +138 -98
- package/dist/impls/supabase-vector.d.ts +29 -33
- package/dist/impls/supabase-vector.d.ts.map +1 -1
- package/dist/impls/supabase-vector.js +278 -103
- package/dist/impls/tldv-meeting-recorder.d.ts +18 -22
- package/dist/impls/tldv-meeting-recorder.d.ts.map +1 -1
- package/dist/impls/tldv-meeting-recorder.js +142 -127
- package/dist/impls/twilio-sms.d.ts +14 -17
- package/dist/impls/twilio-sms.d.ts.map +1 -1
- package/dist/impls/twilio-sms.js +62 -55
- package/dist/index.d.ts +15 -64
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4700 -107
- package/dist/llm.d.ts +1 -8
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +3 -3
- package/dist/meeting-recorder.d.ts +1 -8
- package/dist/meeting-recorder.d.ts.map +1 -1
- package/dist/meeting-recorder.js +3 -3
- package/dist/node/analytics.js +2 -0
- package/dist/node/calendar.js +2 -0
- package/dist/node/database.js +2 -0
- package/dist/node/email.js +2 -0
- package/dist/node/embedding.js +2 -0
- package/dist/node/impls/elevenlabs-voice.js +102 -0
- package/dist/node/impls/fal-voice.js +112 -0
- package/dist/node/impls/fathom-meeting-recorder.js +287 -0
- package/dist/node/impls/fathom-meeting-recorder.mapper.js +105 -0
- package/dist/node/impls/fathom-meeting-recorder.types.js +0 -0
- package/dist/node/impls/fathom-meeting-recorder.utils.js +72 -0
- package/dist/node/impls/fathom-meeting-recorder.webhooks.js +29 -0
- package/dist/node/impls/fireflies-meeting-recorder.js +274 -0
- package/dist/node/impls/fireflies-meeting-recorder.queries.js +85 -0
- package/dist/node/impls/fireflies-meeting-recorder.types.js +0 -0
- package/dist/node/impls/fireflies-meeting-recorder.utils.js +42 -0
- package/dist/node/impls/gcs-storage.js +97 -0
- package/dist/node/impls/gmail-inbound.js +227 -0
- package/dist/node/impls/gmail-outbound.js +139 -0
- package/dist/node/impls/google-calendar.js +191 -0
- package/dist/node/impls/gradium-voice.js +90 -0
- package/dist/node/impls/granola-meeting-recorder.js +512 -0
- package/dist/node/impls/granola-meeting-recorder.mcp.js +278 -0
- package/dist/node/impls/granola-meeting-recorder.types.js +0 -0
- package/dist/node/impls/index.js +4658 -0
- package/dist/node/impls/jira.js +124 -0
- package/dist/node/impls/linear.js +83 -0
- package/dist/node/impls/mistral-embedding.js +43 -0
- package/dist/node/impls/mistral-llm.js +269 -0
- package/dist/node/impls/notion.js +160 -0
- package/dist/node/impls/posthog-reader.js +159 -0
- package/dist/node/impls/posthog-utils.js +38 -0
- package/dist/node/impls/posthog.js +322 -0
- package/dist/node/impls/postmark-email.js +60 -0
- package/dist/node/impls/powens-client.js +195 -0
- package/dist/node/impls/powens-openbanking.js +426 -0
- package/dist/node/impls/provider-factory.js +4080 -0
- package/dist/node/impls/qdrant-vector.js +78 -0
- package/dist/node/impls/stripe-payments.js +228 -0
- package/dist/node/impls/supabase-psql.js +150 -0
- package/dist/node/impls/supabase-vector.js +323 -0
- package/dist/node/impls/tldv-meeting-recorder.js +145 -0
- package/dist/node/impls/twilio-sms.js +65 -0
- package/dist/node/index.js +4699 -0
- package/dist/node/llm.js +2 -0
- package/dist/node/meeting-recorder.js +2 -0
- package/dist/node/openbanking.js +2 -0
- package/dist/node/payments.js +2 -0
- package/dist/node/project-management.js +2 -0
- package/dist/node/runtime.js +0 -0
- package/dist/node/secrets/provider.js +11 -0
- package/dist/node/sms.js +2 -0
- package/dist/node/storage.js +2 -0
- package/dist/node/vector-store.js +2 -0
- package/dist/node/voice.js +2 -0
- package/dist/openbanking.d.ts +1 -8
- package/dist/openbanking.d.ts.map +1 -1
- package/dist/openbanking.js +3 -3
- package/dist/payments.d.ts +1 -8
- package/dist/payments.d.ts.map +1 -1
- package/dist/payments.js +3 -3
- package/dist/project-management.d.ts +1 -8
- package/dist/project-management.d.ts.map +1 -1
- package/dist/project-management.js +3 -3
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +1 -0
- package/dist/secrets/provider.d.ts +3 -2
- package/dist/secrets/provider.d.ts.map +1 -0
- package/dist/secrets/provider.js +12 -3
- package/dist/sms.d.ts +1 -8
- package/dist/sms.d.ts.map +1 -1
- package/dist/sms.js +3 -3
- package/dist/storage.d.ts +1 -8
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +3 -3
- package/dist/vector-store.d.ts +1 -8
- package/dist/vector-store.d.ts.map +1 -1
- package/dist/vector-store.js +3 -3
- package/dist/voice.d.ts +1 -8
- package/dist/voice.d.ts.map +1 -1
- package/dist/voice.js +3 -3
- package/package.json +405 -114
- package/dist/_virtual/_rolldown/runtime.js +0 -36
- package/dist/impls/elevenlabs-voice.js.map +0 -1
- package/dist/impls/fal-voice.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.mapper.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.utils.js.map +0 -1
- package/dist/impls/fathom-meeting-recorder.webhooks.js.map +0 -1
- package/dist/impls/fireflies-meeting-recorder.js.map +0 -1
- package/dist/impls/fireflies-meeting-recorder.queries.js.map +0 -1
- package/dist/impls/fireflies-meeting-recorder.utils.js.map +0 -1
- package/dist/impls/gcs-storage.js.map +0 -1
- package/dist/impls/gmail-inbound.js.map +0 -1
- package/dist/impls/gmail-outbound.js.map +0 -1
- package/dist/impls/google-calendar.js.map +0 -1
- package/dist/impls/gradium-voice.js.map +0 -1
- package/dist/impls/granola-meeting-recorder.js.map +0 -1
- package/dist/impls/jira.js.map +0 -1
- package/dist/impls/linear.js.map +0 -1
- package/dist/impls/mistral-embedding.js.map +0 -1
- package/dist/impls/mistral-llm.js.map +0 -1
- package/dist/impls/notion.js.map +0 -1
- package/dist/impls/posthog-reader.js.map +0 -1
- package/dist/impls/posthog-utils.js.map +0 -1
- package/dist/impls/posthog.js.map +0 -1
- package/dist/impls/postmark-email.js.map +0 -1
- package/dist/impls/powens-client.js.map +0 -1
- package/dist/impls/powens-openbanking.js.map +0 -1
- package/dist/impls/provider-factory.js.map +0 -1
- package/dist/impls/qdrant-vector.js.map +0 -1
- package/dist/impls/stripe-payments.js.map +0 -1
- package/dist/impls/supabase-psql.js.map +0 -1
- package/dist/impls/supabase-vector.js.map +0 -1
- package/dist/impls/tldv-meeting-recorder.js.map +0 -1
- package/dist/impls/twilio-sms.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,30 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
// @bun
|
|
2
|
+
// src/impls/posthog-utils.ts
|
|
2
3
|
function normalizeHost(host) {
|
|
3
|
-
|
|
4
|
+
return host.replace(/\/$/, "");
|
|
4
5
|
}
|
|
5
6
|
function buildUrl(host, path, query) {
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
if (/^https?:\/\//.test(path)) {
|
|
8
|
+
return appendQuery(path, query);
|
|
9
|
+
}
|
|
10
|
+
const normalizedPath = path.replace(/^\/+/, "");
|
|
11
|
+
return appendQuery(`${host}/${normalizedPath}`, query);
|
|
8
12
|
}
|
|
9
13
|
function appendQuery(url, query) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
if (!query)
|
|
15
|
+
return url;
|
|
16
|
+
const params = new URLSearchParams;
|
|
17
|
+
Object.entries(query).forEach(([key, value]) => {
|
|
18
|
+
if (value === undefined)
|
|
19
|
+
return;
|
|
20
|
+
params.set(key, String(value));
|
|
21
|
+
});
|
|
22
|
+
const suffix = params.toString();
|
|
23
|
+
return suffix ? `${url}?${suffix}` : url;
|
|
18
24
|
}
|
|
19
25
|
function parseJson(value) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
if (!value)
|
|
27
|
+
return {};
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse(value);
|
|
30
|
+
} catch {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
26
33
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
export {
|
|
35
|
+
parseJson,
|
|
36
|
+
normalizeHost,
|
|
37
|
+
buildUrl,
|
|
38
|
+
appendQuery
|
|
39
|
+
};
|
package/dist/impls/posthog.d.ts
CHANGED
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fetch?: typeof fetch;
|
|
13
|
-
client?: PostHog;
|
|
1
|
+
import { PostHog } from 'posthog-node';
|
|
2
|
+
import type { AnalyticsAnnotation, AnalyticsCohort, AnalyticsEvent, AnalyticsEventInput, AnalyticsFeatureFlag, AnalyticsIdentifyInput, AnalyticsInsight, AnalyticsMcpToolCall, AnalyticsPerson, AnalyticsProvider, AnalyticsQueryInput, AnalyticsQueryResult, AnalyticsRequest, AnalyticsResponse, GetAnnotationsInput, GetCohortsInput, GetEventsInput, GetFeatureFlagsInput, GetInsightResultInput, GetInsightsInput, GetPersonsInput, PaginatedResponse } from '../analytics';
|
|
3
|
+
export interface PosthogAnalyticsProviderOptions {
|
|
4
|
+
host?: string;
|
|
5
|
+
projectId?: string | number;
|
|
6
|
+
projectApiKey?: string;
|
|
7
|
+
personalApiKey?: string;
|
|
8
|
+
mcpUrl?: string;
|
|
9
|
+
requestTimeoutMs?: number;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
client?: PostHog;
|
|
14
12
|
}
|
|
15
|
-
declare class PosthogAnalyticsProvider implements
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
export declare class PosthogAnalyticsProvider implements AnalyticsProvider {
|
|
14
|
+
private readonly host;
|
|
15
|
+
private readonly projectId?;
|
|
16
|
+
private readonly projectApiKey?;
|
|
17
|
+
private readonly personalApiKey?;
|
|
18
|
+
private readonly mcpUrl?;
|
|
19
|
+
private readonly fetchFn;
|
|
20
|
+
private readonly client?;
|
|
21
|
+
private readonly reader;
|
|
22
|
+
constructor(options: PosthogAnalyticsProviderOptions);
|
|
23
|
+
capture(event: AnalyticsEventInput): Promise<void>;
|
|
24
|
+
identify(input: AnalyticsIdentifyInput): Promise<void>;
|
|
25
|
+
queryHogQL(input: AnalyticsQueryInput): Promise<AnalyticsQueryResult>;
|
|
26
|
+
getEvents(input: GetEventsInput): Promise<PaginatedResponse<AnalyticsEvent>>;
|
|
27
|
+
getPersons(input: GetPersonsInput): Promise<PaginatedResponse<AnalyticsPerson>>;
|
|
28
|
+
getInsights(input: GetInsightsInput): Promise<PaginatedResponse<AnalyticsInsight>>;
|
|
29
|
+
getInsightResult(input: GetInsightResultInput): Promise<AnalyticsInsight>;
|
|
30
|
+
getCohorts(input: GetCohortsInput): Promise<PaginatedResponse<AnalyticsCohort>>;
|
|
31
|
+
getFeatureFlags(input: GetFeatureFlagsInput): Promise<PaginatedResponse<AnalyticsFeatureFlag>>;
|
|
32
|
+
getAnnotations(input: GetAnnotationsInput): Promise<PaginatedResponse<AnalyticsAnnotation>>;
|
|
33
|
+
request<T = unknown>(request: AnalyticsRequest): Promise<AnalyticsResponse<T>>;
|
|
34
|
+
callMcpTool(call: AnalyticsMcpToolCall): Promise<unknown>;
|
|
37
35
|
}
|
|
38
|
-
//#endregion
|
|
39
|
-
export { PosthogAnalyticsProvider, PosthogAnalyticsProviderOptions };
|
|
40
36
|
//# sourceMappingURL=posthog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"posthog.d.ts","
|
|
1
|
+
{"version":3,"file":"posthog.d.ts","sourceRoot":"","sources":["../../src/impls/posthog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAItB,MAAM,WAAW,+BAA+B;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAID,qBAAa,wBAAyB,YAAW,iBAAiB;IAChE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAkB;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAS;IACxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;gBAEpC,OAAO,EAAE,+BAA+B;IAqB9C,OAAO,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAalD,QAAQ,CAAC,KAAK,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAatD,UAAU,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIrE,SAAS,CACb,KAAK,EAAE,cAAc,GACpB,OAAO,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;IAIvC,UAAU,CACd,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAIxC,WAAW,CACf,KAAK,EAAE,gBAAgB,GACtB,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAIzC,gBAAgB,CACpB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,gBAAgB,CAAC;IAItB,UAAU,CACd,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;IAIxC,eAAe,CACnB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;IAI7C,cAAc,CAClB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;IAI5C,OAAO,CAAC,CAAC,GAAG,OAAO,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAwB1B,WAAW,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;CAiChE"}
|
package/dist/impls/posthog.js
CHANGED
|
@@ -1,122 +1,323 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
3
193
|
import { PostHog } from "posthog-node";
|
|
194
|
+
var DEFAULT_POSTHOG_HOST = "https://app.posthog.com";
|
|
4
195
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
118
323
|
};
|
|
119
|
-
|
|
120
|
-
//#endregion
|
|
121
|
-
export { PosthogAnalyticsProvider };
|
|
122
|
-
//# sourceMappingURL=posthog.js.map
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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","
|
|
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"}
|