Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unofficial-substack-sdk",
"version": "0.3.7",
"version": "0.3.8",
"description": "Unofficial, portable TypeScript SDK for Substack's web API",
"type": "module",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export {
type EmailStatsPage,
type EmailStatsRow,
type FetchLike,
type GrowthInterval,
type GrowthMetric,
type GrowthMetricTimeseriesPoint,
type GrowthSourceItem,
Expand Down
12 changes: 12 additions & 0 deletions src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,14 @@ export type UnreadActivityFeed = ActivityFeed & {
unread: UnreadActivityMetadata
}

export interface GrowthInterval<TSource = GrowthSourceItem, TTotal = GrowthTotalItem> {
startDate: string
endDate: string
totals?: TTotal[]
sourceMetrics?: TSource[]
[key: string]: unknown
}

export interface GrowthSourcesOptions {
/** Start date in YYYY-MM-DD format. */
fromDate?: string
Expand All @@ -490,6 +498,8 @@ export interface GrowthSourcesOptions {
orderDirection?: 'asc' | 'desc'
/** Sort direction alias (snake_case). */
order_direction?: 'asc' | 'desc'
/** Trend aggregation granularity: 'total' (default), 'day' (max 31 days), 'week', or 'month'. */
granularity?: 'total' | 'day' | 'week' | 'month'
}

export interface GrowthMetricTimeseriesPoint {
Expand Down Expand Up @@ -533,5 +543,7 @@ export type GrowthSourcesResponse<
> = {
sourceMetrics?: TSource[]
totals?: TTotal[]
granularity?: 'total' | 'day' | 'week' | 'month'
intervals?: GrowthInterval<TSource, TTotal>[]
[key: string]: unknown
}
Loading