@lucaapp/service-utils 1.44.0 → 1.46.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/lib/api/types/utils.d.ts +1 -1
- package/dist/lib/kafka/events/reservation.d.ts +7 -0
- package/dist/lib/kafka/events/reservation.js +2 -0
- package/dist/lib/kafka/events/reservationFee.d.ts +0 -1
- package/dist/lib/kafka/events.d.ts +4 -0
- package/dist/lib/kafka/events.js +2 -0
- package/dist/lib/wsEvent/index.d.ts +3 -1
- package/dist/lib/wsEvent/index.js +13 -1
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ export type ExtractZodOutputFromMiddleware<T> = T extends {
|
|
|
15
15
|
context?: z.ZodSchema<infer V>;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
-
} ? V : undefined;
|
|
18
|
+
} ? V extends object ? V : undefined : undefined;
|
|
19
19
|
export type Always<T> = T extends object ? T : {};
|
|
20
20
|
type AllKeys<T> = T extends any ? keyof T : never;
|
|
21
21
|
type PickType<T, K extends AllKeys<T>> = T extends {
|
|
@@ -8,6 +8,7 @@ import { Service } from '../serviceIdentity';
|
|
|
8
8
|
import { LocationGroup } from './events/locationGroup';
|
|
9
9
|
import { Location } from './events/location';
|
|
10
10
|
import { ReservationFee } from './events/reservationFee';
|
|
11
|
+
import { Reservation } from './events/reservation';
|
|
11
12
|
declare enum KafkaTopic {
|
|
12
13
|
PAYMENTS = "payments",
|
|
13
14
|
CONSUMERS = "consumers",
|
|
@@ -16,6 +17,7 @@ declare enum KafkaTopic {
|
|
|
16
17
|
LOCATION_MENUS = "location_menus",
|
|
17
18
|
LOCATION_GROUPS = "location_groups",
|
|
18
19
|
LOCATION_GROUP_EMPLOYEES = "location_group_employees",
|
|
20
|
+
RESERVATIONS = "reservations",
|
|
19
21
|
RESERVATION_FEES = "reservation_fees",
|
|
20
22
|
WS_EVENT_backend = "wsevent_backend",
|
|
21
23
|
WS_EVENT_backend_pay = "wsevent_backend-pay",
|
|
@@ -29,6 +31,7 @@ type MessageFormats = {
|
|
|
29
31
|
[KafkaTopic.LOCATION_MENUS]: LocationMenu;
|
|
30
32
|
[KafkaTopic.LOCATION_GROUPS]: LocationGroup;
|
|
31
33
|
[KafkaTopic.LOCATION_GROUP_EMPLOYEES]: LocationGroupEmployees;
|
|
34
|
+
[KafkaTopic.RESERVATIONS]: Reservation;
|
|
32
35
|
[KafkaTopic.RESERVATION_FEES]: ReservationFee;
|
|
33
36
|
[KafkaTopic.WS_EVENT_backend]: WsEvent;
|
|
34
37
|
[KafkaTopic.WS_EVENT_backend_pay]: WsEvent;
|
|
@@ -42,6 +45,7 @@ declare const MessageIssuer: {
|
|
|
42
45
|
location_menus: Service;
|
|
43
46
|
location_groups: Service;
|
|
44
47
|
location_group_employees: Service;
|
|
48
|
+
reservations: Service;
|
|
45
49
|
reservation_fees: Service;
|
|
46
50
|
wsevent_backend: Service;
|
|
47
51
|
"wsevent_backend-pay": Service;
|
package/dist/lib/kafka/events.js
CHANGED
|
@@ -11,6 +11,7 @@ var KafkaTopic;
|
|
|
11
11
|
KafkaTopic["LOCATION_MENUS"] = "location_menus";
|
|
12
12
|
KafkaTopic["LOCATION_GROUPS"] = "location_groups";
|
|
13
13
|
KafkaTopic["LOCATION_GROUP_EMPLOYEES"] = "location_group_employees";
|
|
14
|
+
KafkaTopic["RESERVATIONS"] = "reservations";
|
|
14
15
|
KafkaTopic["RESERVATION_FEES"] = "reservation_fees";
|
|
15
16
|
KafkaTopic["WS_EVENT_backend"] = "wsevent_backend";
|
|
16
17
|
KafkaTopic["WS_EVENT_backend_pay"] = "wsevent_backend-pay";
|
|
@@ -25,6 +26,7 @@ const MessageIssuer = {
|
|
|
25
26
|
[KafkaTopic.LOCATION_MENUS]: serviceIdentity_1.Service.BACKEND,
|
|
26
27
|
[KafkaTopic.LOCATION_GROUPS]: serviceIdentity_1.Service.BACKEND,
|
|
27
28
|
[KafkaTopic.LOCATION_GROUP_EMPLOYEES]: serviceIdentity_1.Service.BACKEND,
|
|
29
|
+
[KafkaTopic.RESERVATIONS]: serviceIdentity_1.Service.BACKEND,
|
|
28
30
|
[KafkaTopic.RESERVATION_FEES]: serviceIdentity_1.Service.BACKEND_PAY,
|
|
29
31
|
[KafkaTopic.WS_EVENT_backend]: serviceIdentity_1.Service.BACKEND,
|
|
30
32
|
[KafkaTopic.WS_EVENT_backend_pay]: serviceIdentity_1.Service.BACKEND_PAY,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { KafkaClient } from '../kafka';
|
|
2
2
|
declare const generateSubscriptionId: () => string;
|
|
3
3
|
declare const emitWebsocketEvent: (kafkaClient: KafkaClient, subId: string, type: string, data: any) => Promise<void>;
|
|
4
|
-
|
|
4
|
+
declare const derivePublicSubId: (method: string, path: string) => string;
|
|
5
|
+
declare const deriveSubId: (method: string, path: string, secret: string) => string;
|
|
6
|
+
export { generateSubscriptionId, emitWebsocketEvent, deriveSubId, derivePublicSubId, };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emitWebsocketEvent = exports.generateSubscriptionId = void 0;
|
|
3
|
+
exports.derivePublicSubId = exports.deriveSubId = exports.emitWebsocketEvent = exports.generateSubscriptionId = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
const generateSubscriptionId = () => {
|
|
@@ -25,3 +25,15 @@ data) => {
|
|
|
25
25
|
await kafkaClient.produce(topic, subId, message);
|
|
26
26
|
};
|
|
27
27
|
exports.emitWebsocketEvent = emitWebsocketEvent;
|
|
28
|
+
const derivePublicSubId = (method, path) => {
|
|
29
|
+
return deriveSubId(method, path, 'public');
|
|
30
|
+
};
|
|
31
|
+
exports.derivePublicSubId = derivePublicSubId;
|
|
32
|
+
const deriveSubId = (method, path, secret) => {
|
|
33
|
+
const data = `${method.toLowerCase()}:${path.toLowerCase()}`;
|
|
34
|
+
const hmac = (0, crypto_1.createHmac)('sha256', secret);
|
|
35
|
+
hmac.update(data);
|
|
36
|
+
const subscriptionId = hmac.digest('base64');
|
|
37
|
+
return subscriptionId;
|
|
38
|
+
};
|
|
39
|
+
exports.deriveSubId = deriveSubId;
|