@prodoctors/contracts 1.6.0 → 1.7.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/gen/analytics.ts +114 -1
- package/package.json +1 -1
- package/proto/analytics.proto +81 -0
package/gen/analytics.ts
CHANGED
|
@@ -79,6 +79,86 @@ export interface TopProductsResponse {
|
|
|
79
79
|
items: TopProduct[];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
export interface AnalyticsRangeRequest {
|
|
83
|
+
/** today | 7days | 30days | 12months */
|
|
84
|
+
range?: string | undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface AnalyticsSummary {
|
|
88
|
+
revenue: number;
|
|
89
|
+
orders: number;
|
|
90
|
+
avgCheck: number;
|
|
91
|
+
/** sotuvi bo'lgan filiallar soni */
|
|
92
|
+
pharmacies: number;
|
|
93
|
+
revenueGrowth: number;
|
|
94
|
+
ordersGrowth: number;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface AnalyticsSeriesPoint {
|
|
98
|
+
/** YYYY-MM-DD yoki YYYY-MM */
|
|
99
|
+
period: string;
|
|
100
|
+
revenue: number;
|
|
101
|
+
orders: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface CityBreakdownItem {
|
|
105
|
+
id: string;
|
|
106
|
+
city: string;
|
|
107
|
+
orders: number;
|
|
108
|
+
revenue: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ProductBreakdownItem {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
category: string;
|
|
115
|
+
/** sotilgan birlik soni */
|
|
116
|
+
orders: number;
|
|
117
|
+
revenue: number;
|
|
118
|
+
stock: number;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface PharmacyBreakdownItem {
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
city: string;
|
|
125
|
+
orders: number;
|
|
126
|
+
revenue: number;
|
|
127
|
+
/** % oldingi davrga nisbatan */
|
|
128
|
+
growth: number;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface AnalyticsOverviewResponse {
|
|
132
|
+
summary: AnalyticsSummary | undefined;
|
|
133
|
+
series: AnalyticsSeriesPoint[];
|
|
134
|
+
cities: CityBreakdownItem[];
|
|
135
|
+
topProducts: ProductBreakdownItem[];
|
|
136
|
+
topPharmacies: PharmacyBreakdownItem[];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface SalesAnalyticsResponse {
|
|
140
|
+
summary: AnalyticsSummary | undefined;
|
|
141
|
+
series: AnalyticsSeriesPoint[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface ProductsAnalyticsSummary {
|
|
145
|
+
productsSold: number;
|
|
146
|
+
revenue: number;
|
|
147
|
+
lowStock: number;
|
|
148
|
+
categories: number;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface ProductsAnalyticsResponse {
|
|
152
|
+
summary: ProductsAnalyticsSummary | undefined;
|
|
153
|
+
products: ProductBreakdownItem[];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface PharmaciesAnalyticsResponse {
|
|
157
|
+
summary: AnalyticsSummary | undefined;
|
|
158
|
+
cities: CityBreakdownItem[];
|
|
159
|
+
pharmacies: PharmacyBreakdownItem[];
|
|
160
|
+
}
|
|
161
|
+
|
|
82
162
|
export const ANALYTICS_V1_PACKAGE_NAME = "analytics.v1";
|
|
83
163
|
|
|
84
164
|
export interface AnalyticsServiceClient {
|
|
@@ -89,6 +169,14 @@ export interface AnalyticsServiceClient {
|
|
|
89
169
|
getRecentOrders(request: RecentOrdersRequest): Observable<RecentOrdersResponse>;
|
|
90
170
|
|
|
91
171
|
getTopProducts(request: TopProductsRequest): Observable<TopProductsResponse>;
|
|
172
|
+
|
|
173
|
+
getAnalyticsOverview(request: AnalyticsRangeRequest): Observable<AnalyticsOverviewResponse>;
|
|
174
|
+
|
|
175
|
+
getSalesAnalytics(request: AnalyticsRangeRequest): Observable<SalesAnalyticsResponse>;
|
|
176
|
+
|
|
177
|
+
getProductsAnalytics(request: AnalyticsRangeRequest): Observable<ProductsAnalyticsResponse>;
|
|
178
|
+
|
|
179
|
+
getPharmaciesAnalytics(request: AnalyticsRangeRequest): Observable<PharmaciesAnalyticsResponse>;
|
|
92
180
|
}
|
|
93
181
|
|
|
94
182
|
export interface AnalyticsServiceController {
|
|
@@ -107,11 +195,36 @@ export interface AnalyticsServiceController {
|
|
|
107
195
|
getTopProducts(
|
|
108
196
|
request: TopProductsRequest,
|
|
109
197
|
): Promise<TopProductsResponse> | Observable<TopProductsResponse> | TopProductsResponse;
|
|
198
|
+
|
|
199
|
+
getAnalyticsOverview(
|
|
200
|
+
request: AnalyticsRangeRequest,
|
|
201
|
+
): Promise<AnalyticsOverviewResponse> | Observable<AnalyticsOverviewResponse> | AnalyticsOverviewResponse;
|
|
202
|
+
|
|
203
|
+
getSalesAnalytics(
|
|
204
|
+
request: AnalyticsRangeRequest,
|
|
205
|
+
): Promise<SalesAnalyticsResponse> | Observable<SalesAnalyticsResponse> | SalesAnalyticsResponse;
|
|
206
|
+
|
|
207
|
+
getProductsAnalytics(
|
|
208
|
+
request: AnalyticsRangeRequest,
|
|
209
|
+
): Promise<ProductsAnalyticsResponse> | Observable<ProductsAnalyticsResponse> | ProductsAnalyticsResponse;
|
|
210
|
+
|
|
211
|
+
getPharmaciesAnalytics(
|
|
212
|
+
request: AnalyticsRangeRequest,
|
|
213
|
+
): Promise<PharmaciesAnalyticsResponse> | Observable<PharmaciesAnalyticsResponse> | PharmaciesAnalyticsResponse;
|
|
110
214
|
}
|
|
111
215
|
|
|
112
216
|
export function AnalyticsServiceControllerMethods() {
|
|
113
217
|
return function (constructor: Function) {
|
|
114
|
-
const grpcMethods: string[] = [
|
|
218
|
+
const grpcMethods: string[] = [
|
|
219
|
+
"getDashboardStats",
|
|
220
|
+
"getSalesTrend",
|
|
221
|
+
"getRecentOrders",
|
|
222
|
+
"getTopProducts",
|
|
223
|
+
"getAnalyticsOverview",
|
|
224
|
+
"getSalesAnalytics",
|
|
225
|
+
"getProductsAnalytics",
|
|
226
|
+
"getPharmaciesAnalytics",
|
|
227
|
+
];
|
|
115
228
|
for (const method of grpcMethods) {
|
|
116
229
|
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
117
230
|
GrpcMethod("AnalyticsService", method)(constructor.prototype[method], method, descriptor);
|
package/package.json
CHANGED
package/proto/analytics.proto
CHANGED
|
@@ -69,9 +69,90 @@ message TopProductsResponse {
|
|
|
69
69
|
repeated TopProduct items = 1;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
// ---------------- Analytics sahifalari ----------------
|
|
73
|
+
|
|
74
|
+
message AnalyticsRangeRequest {
|
|
75
|
+
optional string range = 1; // today | 7days | 30days | 12months
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
message AnalyticsSummary {
|
|
79
|
+
double revenue = 1;
|
|
80
|
+
int32 orders = 2;
|
|
81
|
+
double avg_check = 3;
|
|
82
|
+
int32 pharmacies = 4; // sotuvi bo'lgan filiallar soni
|
|
83
|
+
double revenue_growth = 5;
|
|
84
|
+
double orders_growth = 6;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
message AnalyticsSeriesPoint {
|
|
88
|
+
string period = 1; // YYYY-MM-DD yoki YYYY-MM
|
|
89
|
+
double revenue = 2;
|
|
90
|
+
int32 orders = 3;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
message CityBreakdownItem {
|
|
94
|
+
string id = 1;
|
|
95
|
+
string city = 2;
|
|
96
|
+
int32 orders = 3;
|
|
97
|
+
double revenue = 4;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
message ProductBreakdownItem {
|
|
101
|
+
string id = 1;
|
|
102
|
+
string name = 2;
|
|
103
|
+
string category = 3;
|
|
104
|
+
int32 orders = 4; // sotilgan birlik soni
|
|
105
|
+
double revenue = 5;
|
|
106
|
+
int32 stock = 6;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
message PharmacyBreakdownItem {
|
|
110
|
+
string id = 1;
|
|
111
|
+
string name = 2;
|
|
112
|
+
string city = 3;
|
|
113
|
+
int32 orders = 4;
|
|
114
|
+
double revenue = 5;
|
|
115
|
+
double growth = 6; // % oldingi davrga nisbatan
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
message AnalyticsOverviewResponse {
|
|
119
|
+
AnalyticsSummary summary = 1;
|
|
120
|
+
repeated AnalyticsSeriesPoint series = 2;
|
|
121
|
+
repeated CityBreakdownItem cities = 3;
|
|
122
|
+
repeated ProductBreakdownItem top_products = 4;
|
|
123
|
+
repeated PharmacyBreakdownItem top_pharmacies = 5;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
message SalesAnalyticsResponse {
|
|
127
|
+
AnalyticsSummary summary = 1;
|
|
128
|
+
repeated AnalyticsSeriesPoint series = 2;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
message ProductsAnalyticsSummary {
|
|
132
|
+
int32 products_sold = 1;
|
|
133
|
+
double revenue = 2;
|
|
134
|
+
int32 low_stock = 3;
|
|
135
|
+
int32 categories = 4;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
message ProductsAnalyticsResponse {
|
|
139
|
+
ProductsAnalyticsSummary summary = 1;
|
|
140
|
+
repeated ProductBreakdownItem products = 2;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
message PharmaciesAnalyticsResponse {
|
|
144
|
+
AnalyticsSummary summary = 1;
|
|
145
|
+
repeated CityBreakdownItem cities = 2;
|
|
146
|
+
repeated PharmacyBreakdownItem pharmacies = 3;
|
|
147
|
+
}
|
|
148
|
+
|
|
72
149
|
service AnalyticsService {
|
|
73
150
|
rpc GetDashboardStats(DashboardStatsRequest) returns (DashboardStatsResponse);
|
|
74
151
|
rpc GetSalesTrend(SalesTrendRequest) returns (SalesTrendResponse);
|
|
75
152
|
rpc GetRecentOrders(RecentOrdersRequest) returns (RecentOrdersResponse);
|
|
76
153
|
rpc GetTopProducts(TopProductsRequest) returns (TopProductsResponse);
|
|
154
|
+
rpc GetAnalyticsOverview(AnalyticsRangeRequest) returns (AnalyticsOverviewResponse);
|
|
155
|
+
rpc GetSalesAnalytics(AnalyticsRangeRequest) returns (SalesAnalyticsResponse);
|
|
156
|
+
rpc GetProductsAnalytics(AnalyticsRangeRequest) returns (ProductsAnalyticsResponse);
|
|
157
|
+
rpc GetPharmaciesAnalytics(AnalyticsRangeRequest) returns (PharmaciesAnalyticsResponse);
|
|
77
158
|
}
|