@uber-clone/common 1.0.8 → 1.0.9
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/build/events/driver-events.d.ts +37 -0
- package/build/events/driver-events.js +2 -0
- package/build/events/kafka-client.js +31 -30
- package/build/events/passenger-events.d.ts +25 -0
- package/build/events/passenger-events.js +2 -0
- package/build/events/subjects.d.ts +4 -0
- package/build/events/subjects.js +4 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/package.json +2 -2
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Subjects } from "./subjects";
|
|
2
|
+
export interface DriverCreatedEvent {
|
|
3
|
+
type: Subjects.DriverCreated;
|
|
4
|
+
data: {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
email: string;
|
|
8
|
+
phone: string;
|
|
9
|
+
city: string;
|
|
10
|
+
vehicle: {
|
|
11
|
+
make: string;
|
|
12
|
+
model: string;
|
|
13
|
+
year: number;
|
|
14
|
+
plate: string;
|
|
15
|
+
};
|
|
16
|
+
userId: string;
|
|
17
|
+
version: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface DriverUpdatedEvent {
|
|
21
|
+
type: Subjects.DriverUpdated;
|
|
22
|
+
data: {
|
|
23
|
+
id: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
email?: string;
|
|
26
|
+
phone?: string;
|
|
27
|
+
city?: string;
|
|
28
|
+
vehicle?: {
|
|
29
|
+
make: string;
|
|
30
|
+
model: string;
|
|
31
|
+
year: number;
|
|
32
|
+
plate: string;
|
|
33
|
+
};
|
|
34
|
+
userId: string;
|
|
35
|
+
version: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -77,53 +77,54 @@ class KafkaClient {
|
|
|
77
77
|
}
|
|
78
78
|
ensureTopics() {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const replicationFactor = parseInt(process.env.KAFKA_REPLICATION_FACTOR || "-1");
|
|
80
81
|
const topics = [
|
|
81
82
|
// User events
|
|
82
|
-
{ topic: subjects_1.Subjects.UserCreated, partitions: 3, replicationFactor
|
|
83
|
-
{ topic: subjects_1.Subjects.UserUpdated, partitions: 3, replicationFactor
|
|
84
|
-
{ topic: subjects_1.Subjects.UserDeleted, partitions: 3, replicationFactor
|
|
83
|
+
{ topic: subjects_1.Subjects.UserCreated, partitions: 3, replicationFactor },
|
|
84
|
+
{ topic: subjects_1.Subjects.UserUpdated, partitions: 3, replicationFactor },
|
|
85
|
+
{ topic: subjects_1.Subjects.UserDeleted, partitions: 3, replicationFactor },
|
|
85
86
|
{
|
|
86
87
|
topic: subjects_1.Subjects.UserProfileUpdated,
|
|
87
88
|
partitions: 3,
|
|
88
|
-
replicationFactor
|
|
89
|
+
replicationFactor,
|
|
89
90
|
},
|
|
90
91
|
// Auth events
|
|
91
|
-
{ topic: subjects_1.Subjects.UserSignedIn, partitions: 3, replicationFactor
|
|
92
|
-
{ topic: subjects_1.Subjects.UserSignedOut, partitions: 3, replicationFactor
|
|
92
|
+
{ topic: subjects_1.Subjects.UserSignedIn, partitions: 3, replicationFactor },
|
|
93
|
+
{ topic: subjects_1.Subjects.UserSignedOut, partitions: 3, replicationFactor },
|
|
93
94
|
{
|
|
94
95
|
topic: subjects_1.Subjects.UserPasswordChanged,
|
|
95
96
|
partitions: 3,
|
|
96
|
-
replicationFactor
|
|
97
|
+
replicationFactor,
|
|
97
98
|
},
|
|
98
99
|
{
|
|
99
100
|
topic: subjects_1.Subjects.UserAccountLocked,
|
|
100
101
|
partitions: 3,
|
|
101
|
-
replicationFactor
|
|
102
|
+
replicationFactor,
|
|
102
103
|
},
|
|
103
104
|
// // Ride events
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
{ topic: subjects_1.Subjects.RideRequested, partitions: 6, replicationFactor },
|
|
106
|
+
{ topic: subjects_1.Subjects.RideAccepted, partitions: 6, replicationFactor },
|
|
107
|
+
{ topic: subjects_1.Subjects.RideStarted, partitions: 6, replicationFactor },
|
|
108
|
+
{ topic: subjects_1.Subjects.RideCompleted, partitions: 6, replicationFactor },
|
|
109
|
+
{ topic: subjects_1.Subjects.RideCancelled, partitions: 6, replicationFactor },
|
|
109
110
|
// // Driver events
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
111
|
+
{ topic: subjects_1.Subjects.DriverOnline, partitions: 6, replicationFactor },
|
|
112
|
+
{ topic: subjects_1.Subjects.DriverOffline, partitions: 6, replicationFactor },
|
|
113
|
+
{
|
|
114
|
+
topic: subjects_1.Subjects.DriverLocationUpdated,
|
|
115
|
+
partitions: 12,
|
|
116
|
+
replicationFactor,
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
topic: subjects_1.Subjects.DriverRideAccepted,
|
|
120
|
+
partitions: 6,
|
|
121
|
+
replicationFactor,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
topic: subjects_1.Subjects.DriverRideCompleted,
|
|
125
|
+
partitions: 6,
|
|
126
|
+
replicationFactor,
|
|
127
|
+
},
|
|
127
128
|
// // Payment events
|
|
128
129
|
// { topic: Subjects.PaymentInitiated, partitions: 4, replicationFactor: 3 },
|
|
129
130
|
// { topic: Subjects.PaymentCompleted, partitions: 4, replicationFactor: 3 },
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Subjects } from "./subjects";
|
|
2
|
+
export interface PassengerCreatedEvent {
|
|
3
|
+
type: Subjects.PassengerCreated;
|
|
4
|
+
data: {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
email: string;
|
|
8
|
+
phone: string;
|
|
9
|
+
paymentMethod: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
version: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface PassengerUpdatedEvent {
|
|
15
|
+
type: Subjects.PassengerUpdated;
|
|
16
|
+
data: {
|
|
17
|
+
id: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
email?: string;
|
|
20
|
+
phone?: string;
|
|
21
|
+
paymentMethod?: string;
|
|
22
|
+
userId: string;
|
|
23
|
+
version: number;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -17,6 +17,10 @@ export declare enum Subjects {
|
|
|
17
17
|
DriverLocationUpdated = "driver.location-updated",
|
|
18
18
|
DriverRideAccepted = "driver.ride-accepted",
|
|
19
19
|
DriverRideCompleted = "driver.ride-completed",
|
|
20
|
+
DriverCreated = "driver.created",
|
|
21
|
+
DriverUpdated = "driver.updated",
|
|
22
|
+
PassengerCreated = "passenger.created",
|
|
23
|
+
PassengerUpdated = "passenger.updated",
|
|
20
24
|
PaymentInitiated = "payment.initiated",
|
|
21
25
|
PaymentCompleted = "payment.completed",
|
|
22
26
|
PaymentFailed = "payment.failed",
|
package/build/events/subjects.js
CHANGED
|
@@ -26,6 +26,10 @@ var Subjects;
|
|
|
26
26
|
Subjects["DriverLocationUpdated"] = "driver.location-updated";
|
|
27
27
|
Subjects["DriverRideAccepted"] = "driver.ride-accepted";
|
|
28
28
|
Subjects["DriverRideCompleted"] = "driver.ride-completed";
|
|
29
|
+
Subjects["DriverCreated"] = "driver.created";
|
|
30
|
+
Subjects["DriverUpdated"] = "driver.updated";
|
|
31
|
+
Subjects["PassengerCreated"] = "passenger.created";
|
|
32
|
+
Subjects["PassengerUpdated"] = "passenger.updated";
|
|
29
33
|
// Payment events
|
|
30
34
|
Subjects["PaymentInitiated"] = "payment.initiated";
|
|
31
35
|
Subjects["PaymentCompleted"] = "payment.completed";
|
package/build/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export * from "./middlewares/validate-request";
|
|
|
11
11
|
export * from "./events/kafka-client";
|
|
12
12
|
export * from "./events/types";
|
|
13
13
|
export * from "./events/subjects";
|
|
14
|
+
export * from "./events/driver-events";
|
|
15
|
+
export * from "./events/passenger-events";
|
|
14
16
|
export * from "./metrics/app.metrics";
|
|
15
17
|
export * from "./utils/logger";
|
|
16
18
|
export * from "./redis/redis-client";
|
package/build/index.js
CHANGED
|
@@ -27,6 +27,8 @@ __exportStar(require("./middlewares/validate-request"), exports);
|
|
|
27
27
|
__exportStar(require("./events/kafka-client"), exports);
|
|
28
28
|
__exportStar(require("./events/types"), exports);
|
|
29
29
|
__exportStar(require("./events/subjects"), exports);
|
|
30
|
+
__exportStar(require("./events/driver-events"), exports);
|
|
31
|
+
__exportStar(require("./events/passenger-events"), exports);
|
|
30
32
|
__exportStar(require("./metrics/app.metrics"), exports);
|
|
31
33
|
__exportStar(require("./utils/logger"), exports);
|
|
32
34
|
__exportStar(require("./redis/redis-client"), exports);
|
package/package.json
CHANGED