exnet-routing 1.2.14 → 1.2.16
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/core/events/_type.d.ts +63 -0
- package/dist/core/events/_type.js +34 -0
- package/dist/core/events/_utils.d.ts +5 -0
- package/dist/core/events/_utils.js +85 -0
- package/dist/core/events/index.d.ts +2 -0
- package/dist/core/events/index.js +18 -0
- package/dist/events/_chat.d.ts +117 -0
- package/dist/events/_chat.js +64 -0
- package/dist/events/_driver.d.ts +152 -0
- package/dist/events/_driver.js +71 -0
- package/dist/events/_facture.d.ts +66 -0
- package/dist/events/_facture.js +44 -0
- package/dist/events/_manifest.d.ts +66 -0
- package/dist/events/_manifest.js +44 -0
- package/dist/events/_shipping.d.ts +349 -0
- package/dist/events/_shipping.js +187 -0
- package/dist/events/_user.d.ts +117 -0
- package/dist/events/_user.js +64 -0
- package/dist/events/chat.d.ts +117 -0
- package/dist/events/chat.js +64 -0
- package/dist/events/driver.d.ts +152 -0
- package/dist/events/driver.js +71 -0
- package/dist/events/facture.d.ts +66 -0
- package/dist/events/facture.js +44 -0
- package/dist/events/index.d.ts +21 -0
- package/dist/events/index.js +32 -0
- package/dist/events/manifest.d.ts +66 -0
- package/dist/events/manifest.js +44 -0
- package/dist/events/shipping.d.ts +349 -0
- package/dist/events/shipping.js +187 -0
- package/dist/events/user.d.ts +117 -0
- package/dist/events/user.js +64 -0
- package/dist/events_router.d.ts +89 -0
- package/dist/events_router.js +161 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +84 -1
- package/dist/models/_billing_center.d.ts +28 -13
- package/dist/models/_chat_message.d.ts +28 -7
- package/dist/models/_contact.d.ts +28 -7
- package/dist/models/_contact_visible.d.ts +56 -14
- package/dist/models/_customer.d.ts +36 -9
- package/dist/models/_customer.js +12 -3
- package/dist/models/_facture.d.ts +32 -11
- package/dist/models/_facture_line.d.ts +42 -15
- package/dist/models/_historique_action.d.ts +28 -7
- package/dist/models/_information_chauffeur.d.ts +28 -7
- package/dist/models/_information_importante.d.ts +28 -7
- package/dist/models/_livraison_chauffeur.d.ts +28 -7
- package/dist/models/_prise_de_poste.d.ts +28 -7
- package/dist/models/_ramassage_chauffeur.d.ts +28 -7
- package/dist/models/_shipping.d.ts +4 -4
- package/dist/models/_shipping_affected.d.ts +28 -7
- package/dist/models/_shipping_comment.d.ts +28 -7
- package/dist/models/_shipping_course.d.ts +28 -7
- package/dist/models/_shipping_document.d.ts +28 -7
- package/dist/models/_shipping_tracking.d.ts +28 -7
- package/dist/models/_tracking_visible.d.ts +56 -14
- package/dist/models/_user.d.ts +26 -11
- package/dist/models/_user_billing_center.d.ts +60 -18
- package/dist/models/_user_login_historie.d.ts +28 -7
- package/dist/models/_vehicule_affected.d.ts +28 -7
- package/dist/routes/admin.d.ts +1710 -477
- package/dist/routes/events.d.ts +89 -0
- package/dist/routes/events.js +161 -0
- package/dist/routes/ops.d.ts +810 -411
- package/dist/routes/public.d.ts +72 -18
- package/dist/routes/user.d.ts +400 -169
- package/package.json +2 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const WsCategory: {
|
|
3
|
+
readonly SUCCESS: "success";
|
|
4
|
+
readonly ERROR: "error";
|
|
5
|
+
readonly WARNING: "warning";
|
|
6
|
+
readonly INFO: "info";
|
|
7
|
+
};
|
|
8
|
+
export type WsCategoryType = (typeof WsCategory)[keyof typeof WsCategory];
|
|
9
|
+
export declare const WsBasePayloadSchema: z.ZodObject<{
|
|
10
|
+
message: z.ZodString;
|
|
11
|
+
category: z.ZodEnum<["success", "error", "warning", "info"]>;
|
|
12
|
+
type: z.ZodString;
|
|
13
|
+
data: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
message: string;
|
|
16
|
+
type: string;
|
|
17
|
+
category: "error" | "success" | "info" | "warning";
|
|
18
|
+
data: Record<string, any>;
|
|
19
|
+
}, {
|
|
20
|
+
message: string;
|
|
21
|
+
type: string;
|
|
22
|
+
category: "error" | "success" | "info" | "warning";
|
|
23
|
+
data: Record<string, any>;
|
|
24
|
+
}>;
|
|
25
|
+
export type WsBasePayload = z.infer<typeof WsBasePayloadSchema>;
|
|
26
|
+
export type IWsEvent<T extends z.ZodObject<any> = z.ZodObject<any>> = {
|
|
27
|
+
event: string;
|
|
28
|
+
type: string;
|
|
29
|
+
category: WsCategoryType;
|
|
30
|
+
payload: T;
|
|
31
|
+
description?: string;
|
|
32
|
+
rooms?: string[];
|
|
33
|
+
};
|
|
34
|
+
export type NestedEvents = {
|
|
35
|
+
[K: string]: NestedEvents | IWsEvent;
|
|
36
|
+
};
|
|
37
|
+
export declare const IWsEventType: <T extends NestedEvents>(events: T) => T;
|
|
38
|
+
export declare const defineEvent: <T extends z.ZodObject<any>>(event: {
|
|
39
|
+
event: string;
|
|
40
|
+
type: string;
|
|
41
|
+
category: WsCategoryType;
|
|
42
|
+
payload: T;
|
|
43
|
+
description?: string;
|
|
44
|
+
rooms?: string[];
|
|
45
|
+
}) => IWsEvent<T>;
|
|
46
|
+
export declare const isWsEvent: (value: NestedEvents | IWsEvent) => value is IWsEvent;
|
|
47
|
+
export declare const isNestedEvents: (value: NestedEvents | IWsEvent) => value is NestedEvents;
|
|
48
|
+
export type TransformEvents<T extends NestedEvents> = {
|
|
49
|
+
[K in keyof T]: T[K] extends NestedEvents ? TransformEvents<T[K]> : T[K] extends IWsEvent<infer P> ? {
|
|
50
|
+
/** Subscribe to this event */
|
|
51
|
+
on: (callback: (data: z.infer<P>) => void) => () => void;
|
|
52
|
+
/** Emit this event (for testing/mocking) */
|
|
53
|
+
emit: (data: z.infer<P>) => void;
|
|
54
|
+
/** Event name */
|
|
55
|
+
eventName: string;
|
|
56
|
+
/** Event type */
|
|
57
|
+
eventType: string;
|
|
58
|
+
/** Payload schema for validation */
|
|
59
|
+
schema: P;
|
|
60
|
+
} : never;
|
|
61
|
+
};
|
|
62
|
+
export type EventHandler<T extends z.ZodObject<any>> = (data: z.infer<T>) => void;
|
|
63
|
+
export type UnsubscribeFn = () => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isNestedEvents = exports.isWsEvent = exports.defineEvent = exports.IWsEventType = exports.WsBasePayloadSchema = exports.WsCategory = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
// WebSocket event categories
|
|
6
|
+
exports.WsCategory = {
|
|
7
|
+
SUCCESS: "success",
|
|
8
|
+
ERROR: "error",
|
|
9
|
+
WARNING: "warning",
|
|
10
|
+
INFO: "info",
|
|
11
|
+
};
|
|
12
|
+
// Base payload schema for all events
|
|
13
|
+
exports.WsBasePayloadSchema = zod_1.z.object({
|
|
14
|
+
message: zod_1.z.string(),
|
|
15
|
+
category: zod_1.z.enum(["success", "error", "warning", "info"]),
|
|
16
|
+
type: zod_1.z.string(),
|
|
17
|
+
data: zod_1.z.record(zod_1.z.any()),
|
|
18
|
+
});
|
|
19
|
+
// Helper to create event definitions
|
|
20
|
+
const IWsEventType = (events) => events;
|
|
21
|
+
exports.IWsEventType = IWsEventType;
|
|
22
|
+
// Helper to create a single event
|
|
23
|
+
const defineEvent = (event) => event;
|
|
24
|
+
exports.defineEvent = defineEvent;
|
|
25
|
+
// Check if value is an event definition
|
|
26
|
+
const isWsEvent = (value) => {
|
|
27
|
+
return "event" in value && "type" in value && "payload" in value;
|
|
28
|
+
};
|
|
29
|
+
exports.isWsEvent = isWsEvent;
|
|
30
|
+
// Check if value is a nested events group
|
|
31
|
+
const isNestedEvents = (value) => {
|
|
32
|
+
return !(0, exports.isWsEvent)(value);
|
|
33
|
+
};
|
|
34
|
+
exports.isNestedEvents = isNestedEvents;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Socket } from "socket.io-client";
|
|
2
|
+
import { IWsEvent, NestedEvents, TransformEvents } from "./_type";
|
|
3
|
+
export declare const parseWsEvents: <T extends NestedEvents>(events: T, socket: Socket) => TransformEvents<T>;
|
|
4
|
+
export declare const getAllEventNames: (events: NestedEvents, prefix?: string) => string[];
|
|
5
|
+
export declare const getEventByName: (events: NestedEvents, eventName: string) => IWsEvent | undefined;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEventByName = exports.getAllEventNames = exports.parseWsEvents = void 0;
|
|
4
|
+
const _type_1 = require("./_type");
|
|
5
|
+
// Create event handler wrapper with validation
|
|
6
|
+
const createEventHandler = (socket, event) => {
|
|
7
|
+
return {
|
|
8
|
+
on: (callback) => {
|
|
9
|
+
const handler = (data) => {
|
|
10
|
+
// Validate incoming data against schema
|
|
11
|
+
const result = event.payload.safeParse(data);
|
|
12
|
+
if (result.success) {
|
|
13
|
+
callback(result.data);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
console.warn(`[WS] Invalid payload for event ${event.event}:`, result.error.errors);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
socket.on(event.event, handler);
|
|
20
|
+
// Return unsubscribe function
|
|
21
|
+
return () => {
|
|
22
|
+
socket.off(event.event, handler);
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
emit: (data) => {
|
|
26
|
+
// Validate outgoing data
|
|
27
|
+
const result = event.payload.safeParse(data);
|
|
28
|
+
if (result.success) {
|
|
29
|
+
socket.emit(event.event, result.data);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
console.error(`[WS] Invalid payload for emit ${event.event}:`, result.error.errors);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
eventName: event.event,
|
|
36
|
+
eventType: event.type,
|
|
37
|
+
schema: event.payload,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
// Parse nested events recursively
|
|
41
|
+
const parseWsEvents = (events, socket) => {
|
|
42
|
+
const result = {};
|
|
43
|
+
for (const [key, value] of Object.entries(events)) {
|
|
44
|
+
if ((0, _type_1.isWsEvent)(value)) {
|
|
45
|
+
;
|
|
46
|
+
result[key] = createEventHandler(socket, value);
|
|
47
|
+
}
|
|
48
|
+
else if ((0, _type_1.isNestedEvents)(value)) {
|
|
49
|
+
;
|
|
50
|
+
result[key] = (0, exports.parseWsEvents)(value, socket);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
};
|
|
55
|
+
exports.parseWsEvents = parseWsEvents;
|
|
56
|
+
// Get all event names from nested events (useful for debugging)
|
|
57
|
+
const getAllEventNames = (events, prefix = "") => {
|
|
58
|
+
const names = [];
|
|
59
|
+
for (const [key, value] of Object.entries(events)) {
|
|
60
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
61
|
+
if ((0, _type_1.isWsEvent)(value)) {
|
|
62
|
+
names.push(`${path}: ${value.event}`);
|
|
63
|
+
}
|
|
64
|
+
else if ((0, _type_1.isNestedEvents)(value)) {
|
|
65
|
+
names.push(...(0, exports.getAllEventNames)(value, path));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return names;
|
|
69
|
+
};
|
|
70
|
+
exports.getAllEventNames = getAllEventNames;
|
|
71
|
+
// Get event by name (for dynamic access)
|
|
72
|
+
const getEventByName = (events, eventName) => {
|
|
73
|
+
for (const value of Object.values(events)) {
|
|
74
|
+
if ((0, _type_1.isWsEvent)(value) && value.event === eventName) {
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
else if ((0, _type_1.isNestedEvents)(value)) {
|
|
78
|
+
const found = (0, exports.getEventByName)(value, eventName);
|
|
79
|
+
if (found)
|
|
80
|
+
return found;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
};
|
|
85
|
+
exports.getEventByName = getEventByName;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./_type"), exports);
|
|
18
|
+
__exportStar(require("./_utils"), exports);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const chatEvents: {
|
|
3
|
+
messageCreated: import("../core/events/_type").IWsEvent<z.ZodObject<{
|
|
4
|
+
message: z.ZodString;
|
|
5
|
+
category: z.ZodLiteral<"info">;
|
|
6
|
+
type: z.ZodLiteral<"chat_message_created">;
|
|
7
|
+
data: z.ZodObject<{
|
|
8
|
+
chatId: z.ZodNumber;
|
|
9
|
+
message: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
10
|
+
createdAt: z.ZodString;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
createdAt: string;
|
|
13
|
+
message: Record<string, any>;
|
|
14
|
+
chatId: number;
|
|
15
|
+
}, {
|
|
16
|
+
createdAt: string;
|
|
17
|
+
message: Record<string, any>;
|
|
18
|
+
chatId: number;
|
|
19
|
+
}>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
message: string;
|
|
22
|
+
type: "chat_message_created";
|
|
23
|
+
category: "info";
|
|
24
|
+
data: {
|
|
25
|
+
createdAt: string;
|
|
26
|
+
message: Record<string, any>;
|
|
27
|
+
chatId: number;
|
|
28
|
+
};
|
|
29
|
+
}, {
|
|
30
|
+
message: string;
|
|
31
|
+
type: "chat_message_created";
|
|
32
|
+
category: "info";
|
|
33
|
+
data: {
|
|
34
|
+
createdAt: string;
|
|
35
|
+
message: Record<string, any>;
|
|
36
|
+
chatId: number;
|
|
37
|
+
};
|
|
38
|
+
}>>;
|
|
39
|
+
messageRead: import("../core/events/_type").IWsEvent<z.ZodObject<{
|
|
40
|
+
message: z.ZodString;
|
|
41
|
+
category: z.ZodLiteral<"info">;
|
|
42
|
+
type: z.ZodLiteral<"chat_message_read">;
|
|
43
|
+
data: z.ZodObject<{
|
|
44
|
+
chatId: z.ZodNumber;
|
|
45
|
+
messageId: z.ZodNumber;
|
|
46
|
+
userId: z.ZodNumber;
|
|
47
|
+
readAt: z.ZodString;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
userId: number;
|
|
50
|
+
chatId: number;
|
|
51
|
+
messageId: number;
|
|
52
|
+
readAt: string;
|
|
53
|
+
}, {
|
|
54
|
+
userId: number;
|
|
55
|
+
chatId: number;
|
|
56
|
+
messageId: number;
|
|
57
|
+
readAt: string;
|
|
58
|
+
}>;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
message: string;
|
|
61
|
+
type: "chat_message_read";
|
|
62
|
+
category: "info";
|
|
63
|
+
data: {
|
|
64
|
+
userId: number;
|
|
65
|
+
chatId: number;
|
|
66
|
+
messageId: number;
|
|
67
|
+
readAt: string;
|
|
68
|
+
};
|
|
69
|
+
}, {
|
|
70
|
+
message: string;
|
|
71
|
+
type: "chat_message_read";
|
|
72
|
+
category: "info";
|
|
73
|
+
data: {
|
|
74
|
+
userId: number;
|
|
75
|
+
chatId: number;
|
|
76
|
+
messageId: number;
|
|
77
|
+
readAt: string;
|
|
78
|
+
};
|
|
79
|
+
}>>;
|
|
80
|
+
typing: import("../core/events/_type").IWsEvent<z.ZodObject<{
|
|
81
|
+
message: z.ZodString;
|
|
82
|
+
category: z.ZodLiteral<"info">;
|
|
83
|
+
type: z.ZodLiteral<"chat_typing">;
|
|
84
|
+
data: z.ZodObject<{
|
|
85
|
+
chatId: z.ZodNumber;
|
|
86
|
+
userId: z.ZodNumber;
|
|
87
|
+
isTyping: z.ZodBoolean;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
userId: number;
|
|
90
|
+
chatId: number;
|
|
91
|
+
isTyping: boolean;
|
|
92
|
+
}, {
|
|
93
|
+
userId: number;
|
|
94
|
+
chatId: number;
|
|
95
|
+
isTyping: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
message: string;
|
|
99
|
+
type: "chat_typing";
|
|
100
|
+
category: "info";
|
|
101
|
+
data: {
|
|
102
|
+
userId: number;
|
|
103
|
+
chatId: number;
|
|
104
|
+
isTyping: boolean;
|
|
105
|
+
};
|
|
106
|
+
}, {
|
|
107
|
+
message: string;
|
|
108
|
+
type: "chat_typing";
|
|
109
|
+
category: "info";
|
|
110
|
+
data: {
|
|
111
|
+
userId: number;
|
|
112
|
+
chatId: number;
|
|
113
|
+
isTyping: boolean;
|
|
114
|
+
};
|
|
115
|
+
}>>;
|
|
116
|
+
};
|
|
117
|
+
export type ChatEventsType = typeof chatEvents;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chatEvents = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const _type_1 = require("../core/events/_type");
|
|
6
|
+
// Chat payload schemas
|
|
7
|
+
const ChatMessageCreatedPayload = zod_1.z.object({
|
|
8
|
+
message: zod_1.z.string(),
|
|
9
|
+
category: zod_1.z.literal(_type_1.WsCategory.INFO),
|
|
10
|
+
type: zod_1.z.literal("chat_message_created"),
|
|
11
|
+
data: zod_1.z.object({
|
|
12
|
+
chatId: zod_1.z.number(),
|
|
13
|
+
message: zod_1.z.record(zod_1.z.any()),
|
|
14
|
+
createdAt: zod_1.z.string(),
|
|
15
|
+
}),
|
|
16
|
+
});
|
|
17
|
+
const ChatMessageReadPayload = zod_1.z.object({
|
|
18
|
+
message: zod_1.z.string(),
|
|
19
|
+
category: zod_1.z.literal(_type_1.WsCategory.INFO),
|
|
20
|
+
type: zod_1.z.literal("chat_message_read"),
|
|
21
|
+
data: zod_1.z.object({
|
|
22
|
+
chatId: zod_1.z.number(),
|
|
23
|
+
messageId: zod_1.z.number(),
|
|
24
|
+
userId: zod_1.z.number(),
|
|
25
|
+
readAt: zod_1.z.string(),
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
const ChatTypingPayload = zod_1.z.object({
|
|
29
|
+
message: zod_1.z.string(),
|
|
30
|
+
category: zod_1.z.literal(_type_1.WsCategory.INFO),
|
|
31
|
+
type: zod_1.z.literal("chat_typing"),
|
|
32
|
+
data: zod_1.z.object({
|
|
33
|
+
chatId: zod_1.z.number(),
|
|
34
|
+
userId: zod_1.z.number(),
|
|
35
|
+
isTyping: zod_1.z.boolean(),
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
// Export chat events definitions
|
|
39
|
+
exports.chatEvents = (0, _type_1.IWsEventType)({
|
|
40
|
+
messageCreated: (0, _type_1.defineEvent)({
|
|
41
|
+
event: "chat:message_created",
|
|
42
|
+
type: "chat_message_created",
|
|
43
|
+
category: _type_1.WsCategory.INFO,
|
|
44
|
+
payload: ChatMessageCreatedPayload,
|
|
45
|
+
description: "Emitted when a new chat message is created",
|
|
46
|
+
rooms: ["chat:{chatId}", "user:{userId}"],
|
|
47
|
+
}),
|
|
48
|
+
messageRead: (0, _type_1.defineEvent)({
|
|
49
|
+
event: "chat:message_read",
|
|
50
|
+
type: "chat_message_read",
|
|
51
|
+
category: _type_1.WsCategory.INFO,
|
|
52
|
+
payload: ChatMessageReadPayload,
|
|
53
|
+
description: "Emitted when a message is marked as read",
|
|
54
|
+
rooms: ["chat:{chatId}"],
|
|
55
|
+
}),
|
|
56
|
+
typing: (0, _type_1.defineEvent)({
|
|
57
|
+
event: "chat:typing",
|
|
58
|
+
type: "chat_typing",
|
|
59
|
+
category: _type_1.WsCategory.INFO,
|
|
60
|
+
payload: ChatTypingPayload,
|
|
61
|
+
description: "Emitted when a user is typing in a chat",
|
|
62
|
+
rooms: ["chat:{chatId}"],
|
|
63
|
+
}),
|
|
64
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const driverEvents: {
|
|
3
|
+
pickupConfirmed: import("../core/events/_type").IWsEvent<z.ZodObject<{
|
|
4
|
+
message: z.ZodString;
|
|
5
|
+
category: z.ZodLiteral<"success">;
|
|
6
|
+
type: z.ZodLiteral<"driver_pickup_confirmed">;
|
|
7
|
+
data: z.ZodObject<{
|
|
8
|
+
shippingId: z.ZodNumber;
|
|
9
|
+
driverId: z.ZodNumber;
|
|
10
|
+
nom: z.ZodOptional<z.ZodString>;
|
|
11
|
+
prenom: z.ZodOptional<z.ZodString>;
|
|
12
|
+
signature: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
13
|
+
picture: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
date: z.ZodOptional<z.ZodString>;
|
|
15
|
+
heurs: z.ZodOptional<z.ZodString>;
|
|
16
|
+
confirmedAt: z.ZodString;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
shippingId: number;
|
|
19
|
+
driverId: number;
|
|
20
|
+
confirmedAt: string;
|
|
21
|
+
date?: string | undefined;
|
|
22
|
+
nom?: string | undefined;
|
|
23
|
+
prenom?: string | undefined;
|
|
24
|
+
signature?: string | null | undefined;
|
|
25
|
+
heurs?: string | undefined;
|
|
26
|
+
picture?: string | null | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
shippingId: number;
|
|
29
|
+
driverId: number;
|
|
30
|
+
confirmedAt: string;
|
|
31
|
+
date?: string | undefined;
|
|
32
|
+
nom?: string | undefined;
|
|
33
|
+
prenom?: string | undefined;
|
|
34
|
+
signature?: string | null | undefined;
|
|
35
|
+
heurs?: string | undefined;
|
|
36
|
+
picture?: string | null | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
message: string;
|
|
40
|
+
type: "driver_pickup_confirmed";
|
|
41
|
+
category: "success";
|
|
42
|
+
data: {
|
|
43
|
+
shippingId: number;
|
|
44
|
+
driverId: number;
|
|
45
|
+
confirmedAt: string;
|
|
46
|
+
date?: string | undefined;
|
|
47
|
+
nom?: string | undefined;
|
|
48
|
+
prenom?: string | undefined;
|
|
49
|
+
signature?: string | null | undefined;
|
|
50
|
+
heurs?: string | undefined;
|
|
51
|
+
picture?: string | null | undefined;
|
|
52
|
+
};
|
|
53
|
+
}, {
|
|
54
|
+
message: string;
|
|
55
|
+
type: "driver_pickup_confirmed";
|
|
56
|
+
category: "success";
|
|
57
|
+
data: {
|
|
58
|
+
shippingId: number;
|
|
59
|
+
driverId: number;
|
|
60
|
+
confirmedAt: string;
|
|
61
|
+
date?: string | undefined;
|
|
62
|
+
nom?: string | undefined;
|
|
63
|
+
prenom?: string | undefined;
|
|
64
|
+
signature?: string | null | undefined;
|
|
65
|
+
heurs?: string | undefined;
|
|
66
|
+
picture?: string | null | undefined;
|
|
67
|
+
};
|
|
68
|
+
}>>;
|
|
69
|
+
deliveryConfirmed: import("../core/events/_type").IWsEvent<z.ZodObject<{
|
|
70
|
+
message: z.ZodString;
|
|
71
|
+
category: z.ZodLiteral<"success">;
|
|
72
|
+
type: z.ZodLiteral<"driver_delivery_confirmed">;
|
|
73
|
+
data: z.ZodObject<{
|
|
74
|
+
shippingId: z.ZodNumber;
|
|
75
|
+
driverId: z.ZodNumber;
|
|
76
|
+
visibleTo: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
confirmedAt: z.ZodString;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
shippingId: number;
|
|
80
|
+
driverId: number;
|
|
81
|
+
confirmedAt: string;
|
|
82
|
+
visibleTo?: boolean | undefined;
|
|
83
|
+
}, {
|
|
84
|
+
shippingId: number;
|
|
85
|
+
driverId: number;
|
|
86
|
+
confirmedAt: string;
|
|
87
|
+
visibleTo?: boolean | undefined;
|
|
88
|
+
}>;
|
|
89
|
+
}, "strip", z.ZodTypeAny, {
|
|
90
|
+
message: string;
|
|
91
|
+
type: "driver_delivery_confirmed";
|
|
92
|
+
category: "success";
|
|
93
|
+
data: {
|
|
94
|
+
shippingId: number;
|
|
95
|
+
driverId: number;
|
|
96
|
+
confirmedAt: string;
|
|
97
|
+
visibleTo?: boolean | undefined;
|
|
98
|
+
};
|
|
99
|
+
}, {
|
|
100
|
+
message: string;
|
|
101
|
+
type: "driver_delivery_confirmed";
|
|
102
|
+
category: "success";
|
|
103
|
+
data: {
|
|
104
|
+
shippingId: number;
|
|
105
|
+
driverId: number;
|
|
106
|
+
confirmedAt: string;
|
|
107
|
+
visibleTo?: boolean | undefined;
|
|
108
|
+
};
|
|
109
|
+
}>>;
|
|
110
|
+
statusChanged: import("../core/events/_type").IWsEvent<z.ZodObject<{
|
|
111
|
+
message: z.ZodString;
|
|
112
|
+
category: z.ZodLiteral<"info">;
|
|
113
|
+
type: z.ZodLiteral<"driver_status_changed">;
|
|
114
|
+
data: z.ZodObject<{
|
|
115
|
+
driverId: z.ZodNumber;
|
|
116
|
+
oldStatus: z.ZodString;
|
|
117
|
+
newStatus: z.ZodString;
|
|
118
|
+
changedAt: z.ZodString;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
driverId: number;
|
|
121
|
+
oldStatus: string;
|
|
122
|
+
newStatus: string;
|
|
123
|
+
changedAt: string;
|
|
124
|
+
}, {
|
|
125
|
+
driverId: number;
|
|
126
|
+
oldStatus: string;
|
|
127
|
+
newStatus: string;
|
|
128
|
+
changedAt: string;
|
|
129
|
+
}>;
|
|
130
|
+
}, "strip", z.ZodTypeAny, {
|
|
131
|
+
message: string;
|
|
132
|
+
type: "driver_status_changed";
|
|
133
|
+
category: "info";
|
|
134
|
+
data: {
|
|
135
|
+
driverId: number;
|
|
136
|
+
oldStatus: string;
|
|
137
|
+
newStatus: string;
|
|
138
|
+
changedAt: string;
|
|
139
|
+
};
|
|
140
|
+
}, {
|
|
141
|
+
message: string;
|
|
142
|
+
type: "driver_status_changed";
|
|
143
|
+
category: "info";
|
|
144
|
+
data: {
|
|
145
|
+
driverId: number;
|
|
146
|
+
oldStatus: string;
|
|
147
|
+
newStatus: string;
|
|
148
|
+
changedAt: string;
|
|
149
|
+
};
|
|
150
|
+
}>>;
|
|
151
|
+
};
|
|
152
|
+
export type DriverEventsType = typeof driverEvents;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.driverEvents = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const _type_1 = require("../core/events/_type");
|
|
6
|
+
// Driver payload schemas
|
|
7
|
+
const DriverPickupConfirmedPayload = zod_1.z.object({
|
|
8
|
+
message: zod_1.z.string(),
|
|
9
|
+
category: zod_1.z.literal(_type_1.WsCategory.SUCCESS),
|
|
10
|
+
type: zod_1.z.literal("driver_pickup_confirmed"),
|
|
11
|
+
data: zod_1.z.object({
|
|
12
|
+
shippingId: zod_1.z.number(),
|
|
13
|
+
driverId: zod_1.z.number(),
|
|
14
|
+
nom: zod_1.z.string().optional(),
|
|
15
|
+
prenom: zod_1.z.string().optional(),
|
|
16
|
+
signature: zod_1.z.string().nullable().optional(),
|
|
17
|
+
picture: zod_1.z.string().nullable().optional(),
|
|
18
|
+
date: zod_1.z.string().optional(),
|
|
19
|
+
heurs: zod_1.z.string().optional(),
|
|
20
|
+
confirmedAt: zod_1.z.string(),
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
const DriverDeliveryConfirmedPayload = zod_1.z.object({
|
|
24
|
+
message: zod_1.z.string(),
|
|
25
|
+
category: zod_1.z.literal(_type_1.WsCategory.SUCCESS),
|
|
26
|
+
type: zod_1.z.literal("driver_delivery_confirmed"),
|
|
27
|
+
data: zod_1.z.object({
|
|
28
|
+
shippingId: zod_1.z.number(),
|
|
29
|
+
driverId: zod_1.z.number(),
|
|
30
|
+
visibleTo: zod_1.z.boolean().optional(),
|
|
31
|
+
confirmedAt: zod_1.z.string(),
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
const DriverStatusChangedPayload = zod_1.z.object({
|
|
35
|
+
message: zod_1.z.string(),
|
|
36
|
+
category: zod_1.z.literal(_type_1.WsCategory.INFO),
|
|
37
|
+
type: zod_1.z.literal("driver_status_changed"),
|
|
38
|
+
data: zod_1.z.object({
|
|
39
|
+
driverId: zod_1.z.number(),
|
|
40
|
+
oldStatus: zod_1.z.string(),
|
|
41
|
+
newStatus: zod_1.z.string(),
|
|
42
|
+
changedAt: zod_1.z.string(),
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
// Export driver events definitions
|
|
46
|
+
exports.driverEvents = (0, _type_1.IWsEventType)({
|
|
47
|
+
pickupConfirmed: (0, _type_1.defineEvent)({
|
|
48
|
+
event: "driver:pickup_confirmed",
|
|
49
|
+
type: "driver_pickup_confirmed",
|
|
50
|
+
category: _type_1.WsCategory.SUCCESS,
|
|
51
|
+
payload: DriverPickupConfirmedPayload,
|
|
52
|
+
description: "Emitted when a driver confirms pickup",
|
|
53
|
+
rooms: ["shipping:{shippingId}", "role:ROLE_OPS_*"],
|
|
54
|
+
}),
|
|
55
|
+
deliveryConfirmed: (0, _type_1.defineEvent)({
|
|
56
|
+
event: "driver:delivery_confirmed",
|
|
57
|
+
type: "driver_delivery_confirmed",
|
|
58
|
+
category: _type_1.WsCategory.SUCCESS,
|
|
59
|
+
payload: DriverDeliveryConfirmedPayload,
|
|
60
|
+
description: "Emitted when a driver confirms delivery",
|
|
61
|
+
rooms: ["shipping:{shippingId}", "role:ROLE_OPS_*"],
|
|
62
|
+
}),
|
|
63
|
+
statusChanged: (0, _type_1.defineEvent)({
|
|
64
|
+
event: "driver:status_changed",
|
|
65
|
+
type: "driver_status_changed",
|
|
66
|
+
category: _type_1.WsCategory.INFO,
|
|
67
|
+
payload: DriverStatusChangedPayload,
|
|
68
|
+
description: "Emitted when driver status changes",
|
|
69
|
+
rooms: ["role:ROLE_OPS_*"],
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const factureEvents: {
|
|
3
|
+
created: import("../core/events/_type").IWsEvent<z.ZodObject<{
|
|
4
|
+
message: z.ZodString;
|
|
5
|
+
category: z.ZodLiteral<"success">;
|
|
6
|
+
type: z.ZodLiteral<"facture_created">;
|
|
7
|
+
data: z.ZodObject<{
|
|
8
|
+
facture: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
9
|
+
createdAt: z.ZodString;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
createdAt: string;
|
|
12
|
+
facture: Record<string, any>;
|
|
13
|
+
}, {
|
|
14
|
+
createdAt: string;
|
|
15
|
+
facture: Record<string, any>;
|
|
16
|
+
}>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
message: string;
|
|
19
|
+
type: "facture_created";
|
|
20
|
+
category: "success";
|
|
21
|
+
data: {
|
|
22
|
+
createdAt: string;
|
|
23
|
+
facture: Record<string, any>;
|
|
24
|
+
};
|
|
25
|
+
}, {
|
|
26
|
+
message: string;
|
|
27
|
+
type: "facture_created";
|
|
28
|
+
category: "success";
|
|
29
|
+
data: {
|
|
30
|
+
createdAt: string;
|
|
31
|
+
facture: Record<string, any>;
|
|
32
|
+
};
|
|
33
|
+
}>>;
|
|
34
|
+
updated: import("../core/events/_type").IWsEvent<z.ZodObject<{
|
|
35
|
+
message: z.ZodString;
|
|
36
|
+
category: z.ZodLiteral<"info">;
|
|
37
|
+
type: z.ZodLiteral<"facture_updated">;
|
|
38
|
+
data: z.ZodObject<{
|
|
39
|
+
facture: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
40
|
+
updatedAt: z.ZodString;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
updatedAt: string;
|
|
43
|
+
facture: Record<string, any>;
|
|
44
|
+
}, {
|
|
45
|
+
updatedAt: string;
|
|
46
|
+
facture: Record<string, any>;
|
|
47
|
+
}>;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
message: string;
|
|
50
|
+
type: "facture_updated";
|
|
51
|
+
category: "info";
|
|
52
|
+
data: {
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
facture: Record<string, any>;
|
|
55
|
+
};
|
|
56
|
+
}, {
|
|
57
|
+
message: string;
|
|
58
|
+
type: "facture_updated";
|
|
59
|
+
category: "info";
|
|
60
|
+
data: {
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
facture: Record<string, any>;
|
|
63
|
+
};
|
|
64
|
+
}>>;
|
|
65
|
+
};
|
|
66
|
+
export type FactureEventsType = typeof factureEvents;
|