Skip to content

Commit 02951b4

Browse files
committed
feat: Bump version to 1.2.12 in package.json, update TypeScript version, and add DashboardEndpoints with related DTOs for dashboard statistics
1 parent 14116b2 commit 02951b4

5 files changed

Lines changed: 92 additions & 8 deletions

File tree

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
{
22
"name": "commercify-api-client",
3-
"version": "1.2.11",
3+
"version": "1.2.12",
44
"description": "API client for the Commercify backend",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"scripts": {
8-
"build": "tsc"
8+
"build": "rm -rf dist && tsc",
9+
"pack": "pnpm run build && npm pack",
10+
"publish": "pnpm run build && pnpm publish --access public",
11+
"prepublishOnly": "pnpm run build"
912
},
1013
"devDependencies": {
11-
"typescript": "^5.0.0"
14+
"typescript": "^5.9.2"
1215
},
1316
"packageManager": "pnpm@10.12.4+sha512.5ea8b0deed94ed68691c9bad4c955492705c5eeb8a87ef86bc62c74a26b037b08ff9570f108b2e4dbd1dd1a9186fea925e527f141c648e85af45631074680184"
1417
}

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/client/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { UserEndpoints } from "../endpoints/users";
1111
import { PaymentProviderEndpoints } from "../endpoints/payment-providers";
1212
import { AdminEndpoints } from "../endpoints/admin";
1313
import { HealthEndpoints } from "../endpoints/health";
14+
import { DashboardEndpoints } from "../endpoints/dashboard";
1415

1516
export class CommercifyApiClient extends BaseApiClient {
1617
public checkout: CheckoutEndpoints;
@@ -25,6 +26,7 @@ export class CommercifyApiClient extends BaseApiClient {
2526
public paymentProviders: PaymentProviderEndpoints;
2627
public admin: AdminEndpoints;
2728
public health: HealthEndpoints;
29+
public dashboard: DashboardEndpoints;
2830

2931
constructor(baseURL: string) {
3032
super(baseURL);
@@ -40,5 +42,6 @@ export class CommercifyApiClient extends BaseApiClient {
4042
this.paymentProviders = new PaymentProviderEndpoints(this);
4143
this.admin = new AdminEndpoints(this);
4244
this.health = new HealthEndpoints(this);
45+
this.dashboard = new DashboardEndpoints(this);
4346
}
4447
}

src/endpoints/dashboard.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { IApiClient, Mapper } from "../client/base";
2+
import { ResponseDTO } from "../types/contracts";
3+
import { DashboardStats, DashboardStatsRequest } from "../types/dtos";
4+
5+
export class DashboardEndpoints {
6+
constructor(private client: IApiClient) {}
7+
8+
// Payment Management
9+
async getStats<R = ResponseDTO<DashboardStats>>(
10+
input: DashboardStatsRequest,
11+
mapper?: Mapper<ResponseDTO<DashboardStats>, R>
12+
): Promise<R> {
13+
return this.client.post<
14+
DashboardStatsRequest,
15+
ResponseDTO<DashboardStats>,
16+
R
17+
>(`/api/admin/dashboard/stats`, input, mapper);
18+
}
19+
}

src/types/dtos.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,65 @@ export interface CurrencyDTO {
122122
updated_at: string;
123123
}
124124

125+
//////////
126+
// source: dashboard.go
127+
128+
/**
129+
* DashboardStatsRequest represents a request for dashboard statistics
130+
*/
131+
export interface DashboardStatsRequest {
132+
start_date?: string;
133+
end_date?: string;
134+
days?: number /* int */; // Alternative to date range, defaults to 30
135+
}
136+
/**
137+
* PercentageChange represents a percentage change with value and direction
138+
*/
139+
export interface PercentageChange {
140+
value: number /* float64 */; // percentage change (e.g., 15.5 for +15.5%)
141+
direction: string; // "up", "down", or "stable"
142+
}
143+
/**
144+
* DashboardStats represents aggregated dashboard statistics
145+
*/
146+
export interface DashboardStats {
147+
total_revenue: number /* int64 */; // in cents
148+
total_orders: number /* int64 */;
149+
total_customers: number /* int64 */;
150+
new_customers: number /* int64 */;
151+
total_products: number /* int64 */;
152+
low_stock_products: number /* int64 */;
153+
revenue_change?: PercentageChange; // vs previous period
154+
orders_change?: PercentageChange; // vs previous period
155+
recent_orders: RecentOrderSummary[];
156+
top_products: TopProductSummary[];
157+
period_start: string;
158+
period_end: string;
159+
}
160+
/**
161+
* RecentOrderSummary represents a summary of recent orders for dashboard
162+
*/
163+
export interface RecentOrderSummary {
164+
id: number /* uint */;
165+
order_number: string;
166+
customer_name: string;
167+
customer_email: string;
168+
total_amount: number /* int64 */; // in cents
169+
status: string;
170+
created_at: string;
171+
}
172+
/**
173+
* TopProductSummary represents top selling products for dashboard
174+
*/
175+
export interface TopProductSummary {
176+
product_id: number /* uint */;
177+
product_name: string;
178+
variant_id?: number /* uint */;
179+
variant_name?: string;
180+
quantity_sold: number /* int64 */;
181+
revenue: number /* int64 */; // in cents
182+
}
183+
125184
//////////
126185
// source: discount.go
127186

0 commit comments

Comments
 (0)