@prodoctors/contracts 1.5.0 → 1.6.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 +127 -0
- package/package.json +1 -1
- package/proto/analytics.proto +77 -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,127 @@
|
|
|
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 const ANALYTICS_V1_PACKAGE_NAME = "analytics.v1";
|
|
83
|
+
|
|
84
|
+
export interface AnalyticsServiceClient {
|
|
85
|
+
getDashboardStats(request: DashboardStatsRequest): Observable<DashboardStatsResponse>;
|
|
86
|
+
|
|
87
|
+
getSalesTrend(request: SalesTrendRequest): Observable<SalesTrendResponse>;
|
|
88
|
+
|
|
89
|
+
getRecentOrders(request: RecentOrdersRequest): Observable<RecentOrdersResponse>;
|
|
90
|
+
|
|
91
|
+
getTopProducts(request: TopProductsRequest): Observable<TopProductsResponse>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface AnalyticsServiceController {
|
|
95
|
+
getDashboardStats(
|
|
96
|
+
request: DashboardStatsRequest,
|
|
97
|
+
): Promise<DashboardStatsResponse> | Observable<DashboardStatsResponse> | DashboardStatsResponse;
|
|
98
|
+
|
|
99
|
+
getSalesTrend(
|
|
100
|
+
request: SalesTrendRequest,
|
|
101
|
+
): Promise<SalesTrendResponse> | Observable<SalesTrendResponse> | SalesTrendResponse;
|
|
102
|
+
|
|
103
|
+
getRecentOrders(
|
|
104
|
+
request: RecentOrdersRequest,
|
|
105
|
+
): Promise<RecentOrdersResponse> | Observable<RecentOrdersResponse> | RecentOrdersResponse;
|
|
106
|
+
|
|
107
|
+
getTopProducts(
|
|
108
|
+
request: TopProductsRequest,
|
|
109
|
+
): Promise<TopProductsResponse> | Observable<TopProductsResponse> | TopProductsResponse;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function AnalyticsServiceControllerMethods() {
|
|
113
|
+
return function (constructor: Function) {
|
|
114
|
+
const grpcMethods: string[] = ["getDashboardStats", "getSalesTrend", "getRecentOrders", "getTopProducts"];
|
|
115
|
+
for (const method of grpcMethods) {
|
|
116
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
117
|
+
GrpcMethod("AnalyticsService", method)(constructor.prototype[method], method, descriptor);
|
|
118
|
+
}
|
|
119
|
+
const grpcStreamMethods: string[] = [];
|
|
120
|
+
for (const method of grpcStreamMethods) {
|
|
121
|
+
const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method);
|
|
122
|
+
GrpcStreamMethod("AnalyticsService", method)(constructor.prototype[method], method, descriptor);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const ANALYTICS_SERVICE_NAME = "AnalyticsService";
|
package/package.json
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
service AnalyticsService {
|
|
73
|
+
rpc GetDashboardStats(DashboardStatsRequest) returns (DashboardStatsResponse);
|
|
74
|
+
rpc GetSalesTrend(SalesTrendRequest) returns (SalesTrendResponse);
|
|
75
|
+
rpc GetRecentOrders(RecentOrdersRequest) returns (RecentOrdersResponse);
|
|
76
|
+
rpc GetTopProducts(TopProductsRequest) returns (TopProductsResponse);
|
|
77
|
+
}
|