Skip to content

Commit e0255c5

Browse files
chore: wip
1 parent b229621 commit e0255c5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1110
-219
lines changed

examples/analytics-bun-server.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ async function executeCommand(
5959

6060
switch (cmd) {
6161
case 'GetItem':
62-
return docClient.send(new GetCommand(input as Parameters<typeof GetCommand>[0]))
62+
return docClient.send(new GetCommand(input as ConstructorParameters<typeof GetCommand>[0]))
6363
case 'PutItem':
64-
return docClient.send(new PutCommand(input as Parameters<typeof PutCommand>[0]))
64+
return docClient.send(new PutCommand(input as ConstructorParameters<typeof PutCommand>[0]))
6565
case 'UpdateItem':
66-
return docClient.send(new UpdateCommand(input as Parameters<typeof UpdateCommand>[0]))
66+
return docClient.send(new UpdateCommand(input as ConstructorParameters<typeof UpdateCommand>[0]))
6767
case 'DeleteItem':
68-
return docClient.send(new DeleteCommand(input as Parameters<typeof DeleteCommand>[0]))
68+
return docClient.send(new DeleteCommand(input as ConstructorParameters<typeof DeleteCommand>[0]))
6969
case 'Query':
70-
return docClient.send(new QueryCommand(input as Parameters<typeof QueryCommand>[0]))
70+
return docClient.send(new QueryCommand(input as ConstructorParameters<typeof QueryCommand>[0]))
7171
default:
7272
throw new Error(`Unknown command: ${cmd}`)
7373
}
@@ -107,7 +107,7 @@ async function parseRequest(request: Request, url: URL): Promise<AnalyticsReques
107107
params: {}, // Will be populated by router
108108
query: Object.fromEntries(url.searchParams),
109109
body,
110-
headers: Object.fromEntries(request.headers),
110+
headers: Object.fromEntries(request.headers as unknown as Iterable<[string, string]>),
111111
ip: request.headers.get('x-forwarded-for')
112112
|| request.headers.get('cf-connecting-ip')
113113
|| undefined,
@@ -256,7 +256,7 @@ Bun.serve({
256256
params: {},
257257
query: {},
258258
body: {},
259-
headers: Object.fromEntries(request.headers),
259+
headers: Object.fromEntries(request.headers as unknown as Iterable<[string, string]>),
260260
}))
261261
}
262262

examples/analytics-lambda.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,19 @@ async function executeCommand(
117117

118118
switch (cmd) {
119119
case 'GetItem':
120-
return docClient.send(new GetCommand(input as Parameters<typeof GetCommand>[0]))
120+
return docClient.send(new GetCommand(input as ConstructorParameters<typeof GetCommand>[0]))
121121

122122
case 'PutItem':
123-
return docClient.send(new PutCommand(input as Parameters<typeof PutCommand>[0]))
123+
return docClient.send(new PutCommand(input as ConstructorParameters<typeof PutCommand>[0]))
124124

125125
case 'UpdateItem':
126-
return docClient.send(new UpdateCommand(input as Parameters<typeof UpdateCommand>[0]))
126+
return docClient.send(new UpdateCommand(input as ConstructorParameters<typeof UpdateCommand>[0]))
127127

128128
case 'DeleteItem':
129-
return docClient.send(new DeleteCommand(input as Parameters<typeof DeleteCommand>[0]))
129+
return docClient.send(new DeleteCommand(input as ConstructorParameters<typeof DeleteCommand>[0]))
130130

131131
case 'Query':
132-
return docClient.send(new QueryCommand(input as Parameters<typeof QueryCommand>[0]))
132+
return docClient.send(new QueryCommand(input as ConstructorParameters<typeof QueryCommand>[0]))
133133

134134
default:
135135
throw new Error(`Unknown command: ${cmd}`)

src/analytics/Analytics.ts

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,76 +7,52 @@
77
// Types are defined in ./types.ts and models in ./models/
88
// ============================================================================
99

10-
// Re-export all types from types.ts
11-
// Import types for internal use
12-
import type {
13-
AggregatedStats,
14-
AggregationPeriod,
15-
AggregatorOptions,
16-
AnalyticsStoreOptions,
17-
CampaignStats,
18-
Conversion,
19-
CustomEvent,
20-
DashboardSummary,
21-
DateRange,
22-
DeviceStats,
23-
DeviceType,
24-
EventStats,
25-
GeoStats,
26-
Goal,
27-
GoalMatchResult,
28-
GoalStats,
29-
PageStats,
30-
PageView,
31-
PipelineJobConfig,
32-
PipelineJobResult,
33-
QueryOptions,
34-
RealtimeData,
35-
RealtimeStats,
36-
ReferrerStats,
37-
Session,
38-
Site,
39-
TimeSeriesPoint,
40-
TopItem,
41-
TrackingScriptOptions,
10+
// Import types from types.ts for internal use
11+
// Note: Some types are defined locally in this file and exported directly
12+
import {
13+
type AggregatedStats,
14+
type AggregationPeriod,
15+
type AnalyticsStoreOptions,
16+
type CampaignStats,
17+
type CustomEvent,
18+
type DeviceStats,
19+
type DeviceType,
20+
type EventStats,
21+
type GeoStats,
22+
type Goal,
23+
type GoalStats,
24+
type GoalType,
25+
type PageStats,
26+
type PageView,
27+
type RealtimeStats,
28+
type ReferrerStats,
29+
type Session,
30+
type Site,
31+
type SiteSettings,
4232
} from './types'
4333

34+
// Re-export types from types.ts
4435
export type {
4536
AggregatedStats,
46-
AggregationJobStatus,
4737
AggregationPeriod,
48-
AggregatorOptions,
4938
AnalyticsStoreOptions,
5039
CampaignStats,
51-
Conversion,
5240
CustomEvent,
53-
DashboardData,
54-
DashboardSummary,
55-
DateRange,
5641
DeviceStats,
5742
DeviceType,
5843
EventStats,
5944
GeoStats,
6045
Goal,
61-
GoalMatchResult,
62-
GoalPerformance,
6346
GoalStats,
6447
GoalType,
6548
PageStats,
6649
PageView,
67-
PipelineJobConfig,
68-
PipelineJobResult,
69-
QueryOptions,
70-
RealtimeData,
7150
RealtimeStats,
7251
ReferrerStats,
7352
Session,
7453
Site,
7554
SiteSettings,
76-
TimeSeriesPoint,
77-
TopItem,
78-
TrackingScriptOptions,
79-
} from './types'
55+
}
8056

8157
// ============================================================================
8258
// Analytics Store - DynamoDB Operations

src/analytics/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ export function createBunRouter(api: AnalyticsAPI, executeCommand: HandlerContex
929929
params: {},
930930
query: Object.fromEntries(url.searchParams),
931931
body: method !== 'GET' ? await request.json().catch(() => ({})) : {},
932-
headers: Object.fromEntries(request.headers),
932+
headers: Object.fromEntries(request.headers as unknown as Iterable<[string, string]>),
933933
ip: request.headers.get('x-forwarded-for') || request.headers.get('cf-connecting-ip') || undefined,
934934
userAgent: request.headers.get('user-agent') || undefined,
935935
}

src/analytics/infrastructure/cloudformation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ export function generateSamTemplate(config: CloudFormationConfig = {}): Record<s
370370
},
371371

372372
Parameters: {
373-
...(cfnTemplate as Record<string, unknown>).Parameters,
373+
...((cfnTemplate as Record<string, unknown>).Parameters as Record<string, unknown> || {}),
374374
CorsOrigins: {
375375
Type: 'String',
376376
Default: '*',

src/analytics/models/AggregatedStats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Model } from '@stacksjs/types'
1+
import type { Model } from './types'
22

33
/**
44
* Aggregated stats (pre-computed for fast dashboard queries)

src/analytics/models/CampaignStats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Model } from '@stacksjs/types'
1+
import type { Model } from './types'
22

33
/**
44
* UTM Campaign stats

src/analytics/models/Conversion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Model } from '@stacksjs/types'
1+
import type { Model } from './types'
22

33
/**
44
* Conversion record (goal completion)

src/analytics/models/CustomEvent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Model } from '@stacksjs/types'
1+
import type { Model } from './types'
22

33
/**
44
* Custom event (non-pageview events like button clicks, form submissions)

src/analytics/models/DeviceStats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Model } from '@stacksjs/types'
1+
import type { Model } from './types'
22

33
/**
44
* Device/Browser stats

0 commit comments

Comments
 (0)