@prodoctors/contracts 1.5.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/dist/proto/paths.d.ts +1 -0
- package/dist/proto/paths.js +1 -0
- package/gen/analytics.ts +240 -0
- package/package.json +1 -1
- package/proto/analytics.proto +158 -0
package/dist/proto/paths.d.ts
CHANGED
package/dist/proto/paths.js
CHANGED
|
@@ -13,4 +13,5 @@ exports.PROTO_PATHS = {
|
|
|
13
13
|
SALES: (0, path_1.join)(__dirname, "../../proto/sales.proto"),
|
|
14
14
|
SHIFT: (0, path_1.join)(__dirname, "../../proto/shift.proto"),
|
|
15
15
|
RESERVATION: (0, path_1.join)(__dirname, "../../proto/reservation.proto"),
|
|
16
|
+
ANALYTICS: (0, path_1.join)(__dirname, "../../proto/analytics.proto"),
|
|
16
17
|
};
|
package/gen/analytics.ts
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-ts_proto v2.11.5
|
|
4
|
+
// protoc v7.34.0
|
|
5
|
+
// source: analytics.proto
|
|
6
|
+
|
|
7
|
+
/* eslint-disable */
|
|
8
|
+
import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices";
|
|
9
|
+
import { Observable } from "rxjs";
|
|
10
|
+
|
|
11
|
+
export const protobufPackage = "analytics.v1";
|
|
12
|
+
|
|
13
|
+
export interface DashboardStatsRequest {
|
|
14
|
+
/** today | 7days | 30days | 12months (default: today) */
|
|
15
|
+
range?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface DashboardStatsResponse {
|
|
19
|
+
revenue: number;
|
|
20
|
+
/** % oldingi teng davrga nisbatan */
|
|
21
|
+
revenueGrowth: number;
|
|
22
|
+
orders: number;
|
|
23
|
+
ordersGrowth: number;
|
|
24
|
+
users: number;
|
|
25
|
+
usersGrowth: number;
|
|
26
|
+
products: number;
|
|
27
|
+
productsGrowth: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SalesTrendRequest {
|
|
31
|
+
/** default 12 */
|
|
32
|
+
months?: number | undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SalesTrendPoint {
|
|
36
|
+
/** "YYYY-MM" */
|
|
37
|
+
period: string;
|
|
38
|
+
revenue: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface SalesTrendResponse {
|
|
42
|
+
points: SalesTrendPoint[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface RecentOrdersRequest {
|
|
46
|
+
/** default 10 */
|
|
47
|
+
limit?: number | undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface RecentOrder {
|
|
51
|
+
id: string;
|
|
52
|
+
orderNumber: string;
|
|
53
|
+
pharmacy: string;
|
|
54
|
+
city: string;
|
|
55
|
+
amount: number;
|
|
56
|
+
/** SaleStatus (admin UI holatga o'giradi) */
|
|
57
|
+
status: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface RecentOrdersResponse {
|
|
61
|
+
items: RecentOrder[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface TopProductsRequest {
|
|
65
|
+
/** default 5 */
|
|
66
|
+
limit?: number | undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface TopProduct {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
category: string;
|
|
73
|
+
stock: number;
|
|
74
|
+
price: number;
|
|
75
|
+
soldQuantity: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface TopProductsResponse {
|
|
79
|
+
items: TopProduct[];
|
|
80
|
+
}
|
|
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
|
+
|
|
162
|
+
export const ANALYTICS_V1_PACKAGE_NAME = "analytics.v1";
|
|
163
|
+
|
|
164
|
+
export interface AnalyticsServiceClient {
|
|
165
|
+
getDashboardStats(request: DashboardStatsRequest): Observable<DashboardStatsResponse>;
|
|
166
|
+
|
|
167
|
+
getSalesTrend(request: SalesTrendRequest): Observable<SalesTrendResponse>;
|
|
168
|
+
|
|
169
|
+
getRecentOrders(request: RecentOrdersRequest): Observable<RecentOrdersResponse>;
|
|
170
|
+
|
|
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>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface AnalyticsServiceController {
|
|
183
|
+
getDashboardStats(
|
|
184
|
+
request: DashboardStatsRequest,
|
|
185
|
+
): Promise<DashboardStatsResponse> | Observable<DashboardStatsResponse> | DashboardStatsResponse;
|
|
186
|
+
|
|
187
|
+
getSalesTrend(
|
|
188
|
+
request: SalesTrendRequest,
|
|
189
|
+
): Promise<SalesTrendResponse> | Observable<SalesTrendResponse> | SalesTrendResponse;
|
|
190
|
+
|
|
191
|
+
getRecentOrders(
|
|
192
|
+
request: RecentOrdersRequest,
|
|
193
|
+
): Promise<RecentOrdersResponse> | Observable<RecentOrdersResponse> | RecentOrdersResponse;
|
|
194
|
+
|
|
195
|
+
getTopProducts(
|
|
196
|
+
request: TopProductsRequest,
|
|
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;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function AnalyticsServiceControllerMethods() {
|
|
217
|
+
return function (constructor: Function) {
|
|
218
|
+
const grpcMethods: string[] = [
|
|
219
|
+
"getDashboardStats",
|
|
220
|
+
"getSalesTrend",
|
|
221
|
+
"getRecentOrders",
|
|
222
|
+
"getTopProducts",
|
|
223
|
+
"getAnalyticsOverview",
|
|
224
|
+
"getSalesAnalytics",
|
|
225
|
+
"getProductsAnalytics",
|
|
226
|
+
"getPharmaciesAnalytics",
|
|
227
|
+
];
|
|
228
|
+
for (const method of grpcMethods) {
|
|
229
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
230
|
+
GrpcMethod("AnalyticsService", method)(constructor.prototype[method], method, descriptor);
|
|
231
|
+
}
|
|
232
|
+
const grpcStreamMethods: string[] = [];
|
|
233
|
+
for (const method of grpcStreamMethods) {
|
|
234
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
235
|
+
GrpcStreamMethod("AnalyticsService", method)(constructor.prototype[method], method, descriptor);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export const ANALYTICS_SERVICE_NAME = "AnalyticsService";
|
package/package.json
CHANGED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
|
|
3
|
+
package analytics.v1;
|
|
4
|
+
|
|
5
|
+
// Admin analitikasi: xom aggregatlar (POS SaleOrder asosida). Display
|
|
6
|
+
// formatlash (i18n kalitlar, valyuta) frontend zimmasida.
|
|
7
|
+
|
|
8
|
+
// ---------------- Dashboard (admin bosh sahifa) ----------------
|
|
9
|
+
|
|
10
|
+
message DashboardStatsRequest {
|
|
11
|
+
optional string range = 1; // today | 7days | 30days | 12months (default: today)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
message DashboardStatsResponse {
|
|
15
|
+
double revenue = 1;
|
|
16
|
+
double revenue_growth = 2; // % oldingi teng davrga nisbatan
|
|
17
|
+
int32 orders = 3;
|
|
18
|
+
double orders_growth = 4;
|
|
19
|
+
int32 users = 5;
|
|
20
|
+
double users_growth = 6;
|
|
21
|
+
int32 products = 7;
|
|
22
|
+
double products_growth = 8;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
message SalesTrendRequest {
|
|
26
|
+
optional int32 months = 1; // default 12
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
message SalesTrendPoint {
|
|
30
|
+
string period = 1; // "YYYY-MM"
|
|
31
|
+
double revenue = 2;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
message SalesTrendResponse {
|
|
35
|
+
repeated SalesTrendPoint points = 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
message RecentOrdersRequest {
|
|
39
|
+
optional int32 limit = 1; // default 10
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
message RecentOrder {
|
|
43
|
+
string id = 1;
|
|
44
|
+
string order_number = 2;
|
|
45
|
+
string pharmacy = 3;
|
|
46
|
+
string city = 4;
|
|
47
|
+
double amount = 5;
|
|
48
|
+
string status = 6; // SaleStatus (admin UI holatga o'giradi)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
message RecentOrdersResponse {
|
|
52
|
+
repeated RecentOrder items = 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
message TopProductsRequest {
|
|
56
|
+
optional int32 limit = 1; // default 5
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
message TopProduct {
|
|
60
|
+
string id = 1;
|
|
61
|
+
string name = 2;
|
|
62
|
+
string category = 3;
|
|
63
|
+
int32 stock = 4;
|
|
64
|
+
double price = 5;
|
|
65
|
+
double sold_quantity = 6;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
message TopProductsResponse {
|
|
69
|
+
repeated TopProduct items = 1;
|
|
70
|
+
}
|
|
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
|
+
|
|
149
|
+
service AnalyticsService {
|
|
150
|
+
rpc GetDashboardStats(DashboardStatsRequest) returns (DashboardStatsResponse);
|
|
151
|
+
rpc GetSalesTrend(SalesTrendRequest) returns (SalesTrendResponse);
|
|
152
|
+
rpc GetRecentOrders(RecentOrdersRequest) returns (RecentOrdersResponse);
|
|
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);
|
|
158
|
+
}
|