serve-socket 1.0.11 → 1.0.12

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.
@@ -0,0 +1,530 @@
1
+ import * as i0 from '@angular/core';
2
+ import { NgModule, InjectionToken, Inject, Injectable, inject } from '@angular/core';
3
+ import { CommonModule } from '@angular/common';
4
+ import { HttpClientModule, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
5
+ import { BehaviorSubject, Subject, firstValueFrom } from 'rxjs';
6
+ import { io } from 'socket.io-client';
7
+
8
+ /**
9
+ * @deprecated Use provideRealtimeStore() with standalone components instead
10
+ */
11
+ class RealtimeStoreModule {
12
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: RealtimeStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
13
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.14", ngImport: i0, type: RealtimeStoreModule, imports: [CommonModule,
14
+ HttpClientModule // Kept for backward compatibility with Angular <14
15
+ ] });
16
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: RealtimeStoreModule, imports: [CommonModule,
17
+ HttpClientModule // Kept for backward compatibility with Angular <14
18
+ ] });
19
+ }
20
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: RealtimeStoreModule, decorators: [{
21
+ type: NgModule,
22
+ args: [{
23
+ declarations: [],
24
+ imports: [
25
+ CommonModule,
26
+ HttpClientModule // Kept for backward compatibility with Angular <14
27
+ ],
28
+ exports: []
29
+ }]
30
+ }] });
31
+
32
+ const defaultRealtimeStoreEnvironment = {
33
+ // apiUrl: `http://${window.location.hostname}:3030`,
34
+ apiUrl: `http://${window.location.hostname}:3030`,
35
+ };
36
+
37
+ const REALTIME_STORE_ENVIRONMENT = new InjectionToken('REALTIME_STORE_ENVIRONMENT');
38
+
39
+ /**
40
+ * API Gateway
41
+ *
42
+ *
43
+ *
44
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
45
+ * https://openapi-generator.tech
46
+ * Do not edit the class manually.
47
+ */
48
+ var SocketGateways;
49
+ (function (SocketGateways) {
50
+ SocketGateways.ResponseEnum = {
51
+ CustomerCreateCartSuccess: 'customer:create:cart:success',
52
+ CustomerRemoveFromCartSuccess: 'customer:remove:from:cart:success',
53
+ CustomerGetMenuSuccess: 'customer:get:menu:success',
54
+ TableJoinRequestSuccess: 'table:join:request:success',
55
+ TableJoinRequestApprovedSuccess: 'table:join:request:approved:success',
56
+ ErrorMessageSuccess: 'error:message:success',
57
+ SuccessMessageSuccess: 'success:message:success',
58
+ WarningMessageSuccess: 'warning:message:success',
59
+ AuthCustomerLoginPendingGetSuccess: 'auth:customer:login:pending:get:success',
60
+ CustomerUpdateIsPaidSuccess: 'customer:update:is-paid:success',
61
+ TableCreatedSuccess: 'table:created:success',
62
+ TableAssignedSuccess: 'table:assigned:success',
63
+ TableStatusUpdatedSuccess: 'table:status:updated:success',
64
+ TableReleasedSuccess: 'table:released:success'
65
+ };
66
+ SocketGateways.RequestEnum = {
67
+ AuthCustomerLogin: 'auth:customer:login',
68
+ AuthCustomerLoginReconnect: 'auth:customer:login:reconnect',
69
+ PosLogin: 'pos:login',
70
+ CustomerGetCart: 'customer:get:cart',
71
+ CustomerGetOneCart: 'customer:get-one:cart',
72
+ CustomerRemoveFromCart: 'customer:remove:from:cart',
73
+ CustomerUpdateCart: 'customer:update:cart',
74
+ GetCartByWaiter: 'get:cart:by:waiter',
75
+ GetAllCarts: 'get:all:carts',
76
+ CustomerGetMenu: 'customer:get:menu',
77
+ ErrorMessage: 'error:message',
78
+ SuccessMessage: 'success:message',
79
+ JoinRoom: 'join:room',
80
+ GetTheming: 'get:theming',
81
+ CustomerCartItemStatusUpdate: 'customer:cart:item:status:update',
82
+ CustomerGetMenuItemReviews: 'customer:get:menu-item:reviews',
83
+ CustomerCreateMenuItemReview: 'customer:create:menu-item:review',
84
+ CustomerGetRequestsByTable: 'customer:get:requests:by:table',
85
+ WaiterGetRequestsByTable: 'waiter:get:requests:by:table',
86
+ CustomerCallWaiter: 'customer:call:waiter',
87
+ WaiterReceiveCall: 'waiter:receive:call',
88
+ WaiterCallAcknowledged: 'waiter:call:acknowledged',
89
+ CustomerGetCallWaiterRequests: 'customer:get:call:waiter:requests',
90
+ WaiterGetCalls: 'waiter:get:calls',
91
+ WaiterGetAvailable: 'waiter:get:available',
92
+ WaiterCallCreate: 'waiter:call:create',
93
+ WaiterCallResolve: 'waiter:call:resolve',
94
+ TableAssignToWaiter: 'table:assign:to:waiter',
95
+ AuthCustomerLoginApprove: 'auth:customer:login:approve',
96
+ AuthCustomerLoginPendingGet: 'auth:customer:login:pending:get',
97
+ AuthCustomerApprovalPendingGetSuccess: 'auth:customer:approval:pending:get:success',
98
+ AuthCustomerApprovalPendingGetForWaiter: 'auth:customer:approval:pending:get:for:waiter',
99
+ PosLogin2: 'pos:login',
100
+ PosValidateBranchCode: 'pos:validate:branch:code',
101
+ PosWaiterLogin: 'pos:waiter:login',
102
+ WaiterGetTables: 'waiter:get:tables',
103
+ WaiterGetLoggedIn: 'waiter:get:logged:in',
104
+ TableGetAll: 'table:get:all',
105
+ TableCreate: 'table:create',
106
+ TableAssign: 'table:assign',
107
+ TableUpdateStatus: 'table:update:status',
108
+ TableRelease: 'table:release',
109
+ WaiterGetTablesDetails: 'waiter:get:tables:details',
110
+ TableGetDetails: 'table:get:details',
111
+ PosWaiterCreate: 'pos:waiter:create'
112
+ };
113
+ })(SocketGateways || (SocketGateways = {}));
114
+
115
+ // Define string constants instead of enum to avoid type errors with string values
116
+ const SocketEvents = {
117
+ CUSTOMER_CONNECT: SocketGateways.RequestEnum.AuthCustomerLogin,
118
+ CUSTOMER_RECONNECT: SocketGateways.RequestEnum.AuthCustomerLoginReconnect,
119
+ CUSTOMER_GET_CART: SocketGateways.RequestEnum.CustomerGetCart,
120
+ CUSTOMER_GET_ONE_CART: SocketGateways.RequestEnum.CustomerGetOneCart,
121
+ CUSTOMER_REMOVE_FROM_CART: SocketGateways.RequestEnum.CustomerRemoveFromCart,
122
+ CUSTOMER_CREATE_UPDATE_CART: SocketGateways.RequestEnum.CustomerUpdateCart,
123
+ CUSTOMER_GET_MENU: SocketGateways.RequestEnum.CustomerGetMenu,
124
+ ERROR_MESSAGE: SocketGateways.RequestEnum.ErrorMessage,
125
+ SUCCESS_MESSAGE: SocketGateways.RequestEnum.SuccessMessage,
126
+ JOIN_ROOM: SocketGateways.RequestEnum.JoinRoom,
127
+ GET_THEMING: SocketGateways.RequestEnum.GetTheming,
128
+ CUSTOMER_CART_ITEM_STATUS_UPDATE: SocketGateways.RequestEnum.CustomerCartItemStatusUpdate,
129
+ CUSTOMER_GET_MENU_ITEM_REVIEWS: SocketGateways.RequestEnum.CustomerGetMenuItemReviews,
130
+ CUSTOMER_CREATE_MENU_ITEM_REVIEW: SocketGateways.RequestEnum.CustomerCreateMenuItemReview,
131
+ CUSTOMER_GET_REQUESTS_BY_TABLE: SocketGateways.RequestEnum.CustomerGetRequestsByTable,
132
+ WAITER_GET_REQUESTS_BY_TABLE: SocketGateways.RequestEnum.WaiterGetRequestsByTable,
133
+ CUSTOMER_CALL_WAITER: SocketGateways.RequestEnum.CustomerCallWaiter,
134
+ WAITER_RECEIVE_CALL: SocketGateways.RequestEnum.WaiterReceiveCall,
135
+ WAITER_CALL_ACKNOWLEDGED: SocketGateways.RequestEnum.WaiterCallAcknowledged,
136
+ CUSTOMER_GET_CALL_WAITER_REQUESTS: SocketGateways.RequestEnum.CustomerGetCallWaiterRequests,
137
+ APPROVE_CUSTOMER_LOGIN: SocketGateways.RequestEnum.AuthCustomerLoginApprove,
138
+ GET_PENDING_CUSTOMER_LOGINS: SocketGateways.RequestEnum.AuthCustomerLoginPendingGet,
139
+ POS_LOGIN: SocketGateways.RequestEnum.PosLogin,
140
+ GET_ALL_TABLES: SocketGateways.RequestEnum.TableGetAll,
141
+ CREATE_TABLE: SocketGateways.RequestEnum.TableCreate,
142
+ ASSIGN_TABLE: SocketGateways.RequestEnum.TableAssign,
143
+ UPDATE_TABLE_STATUS: SocketGateways.RequestEnum.TableUpdateStatus,
144
+ RELEASE_TABLE: SocketGateways.RequestEnum.TableRelease
145
+ };
146
+ const SocketSuccessEvents = {
147
+ // Map to SocketGateways.ResponseEnum
148
+ CUSTOMER_CREATE_OR_UPDATE_CART_SUCCESS: SocketGateways.ResponseEnum.CustomerCreateCartSuccess,
149
+ CUSTOMER_REMOVE_FROM_CART_SUCCESS: SocketGateways.ResponseEnum.CustomerRemoveFromCartSuccess,
150
+ CUSTOMER_GET_MENU_SUCCESS: SocketGateways.ResponseEnum.CustomerGetMenuSuccess,
151
+ TABLE_JOIN_REQUEST_SENT_SUCCESS: SocketGateways.ResponseEnum.TableJoinRequestSuccess,
152
+ TABLE_JOIN_REQUEST_APPROVED_SUCCESS: SocketGateways.ResponseEnum.TableJoinRequestApprovedSuccess,
153
+ ERROR_MESSAGE_SUCCESS: SocketGateways.ResponseEnum.ErrorMessageSuccess,
154
+ SUCCESS_MESSAGE_SUCCESS: SocketGateways.ResponseEnum.SuccessMessageSuccess,
155
+ WARNING_MESSAGE_SUCCESS: SocketGateways.ResponseEnum.WarningMessageSuccess,
156
+ GET_PENDING_CUSTOMER_LOGINS_SUCCESS: SocketGateways.ResponseEnum.AuthCustomerLoginPendingGetSuccess,
157
+ CUSTOMER_UPDATE_IS_PAID_SUCCESS: SocketGateways.ResponseEnum.CustomerUpdateIsPaidSuccess,
158
+ TABLE_CREATED: SocketGateways.ResponseEnum.TableCreatedSuccess,
159
+ TABLE_ASSIGNED: SocketGateways.ResponseEnum.TableAssignedSuccess,
160
+ TABLE_STATUS_UPDATED: SocketGateways.ResponseEnum.TableStatusUpdatedSuccess,
161
+ TABLE_RELEASED: SocketGateways.ResponseEnum.TableReleasedSuccess,
162
+ // Add WAITER_RECEIVE_CALL which appears to be missing from the ResponseEnum
163
+ WAITER_RECEIVE_CALL: 'waiter:receive:call'
164
+ };
165
+ class SocketService {
166
+ environment;
167
+ socket;
168
+ url;
169
+ authToken;
170
+ connectionKey;
171
+ eventSubjects = new Map();
172
+ connectionStatusSubject = new BehaviorSubject(false);
173
+ connectionStatus$ = this.connectionStatusSubject.asObservable();
174
+ reconnectSubject = new Subject();
175
+ reconnect$ = this.reconnectSubject.asObservable();
176
+ constructor(environment = defaultRealtimeStoreEnvironment) {
177
+ this.environment = environment;
178
+ this.url = this.environment.apiUrl;
179
+ this.setupSocketConnection();
180
+ }
181
+ setupSocketConnection() {
182
+ const socketOptions = {
183
+ transports: ['websocket'],
184
+ autoConnect: true
185
+ };
186
+ // Add auth if token is available
187
+ if (this.authToken) {
188
+ socketOptions.auth = {
189
+ token: this.authToken
190
+ };
191
+ }
192
+ this.socket = io(this.url, socketOptions);
193
+ this.socket.on('connect', () => {
194
+ console.log('Socket connected');
195
+ this.connectionStatusSubject.next(true);
196
+ this.reestablishListeners();
197
+ });
198
+ this.socket.on('disconnect', () => {
199
+ console.log('Socket disconnected');
200
+ this.connectionStatusSubject.next(false);
201
+ });
202
+ this.socket.on('reconnect', () => {
203
+ console.log('Socket reconnected');
204
+ this.connectionStatusSubject.next(true);
205
+ this.reconnectSubject.next();
206
+ this.reestablishListeners();
207
+ });
208
+ this.socket.on('connect_error', (err) => {
209
+ console.error('Connection error:', err.message);
210
+ });
211
+ this.socket.on('reconnect_error', (err) => {
212
+ console.error('Reconnection error:', err.message);
213
+ });
214
+ }
215
+ reestablishListeners() {
216
+ console.log('Re-establishing listeners for', this.eventSubjects.size, 'events');
217
+ this.eventSubjects.forEach((subject, eventName) => {
218
+ this.socket.on(eventName, (data) => {
219
+ subject.next(data);
220
+ });
221
+ });
222
+ }
223
+ /**
224
+ * Set authentication token for socket connection
225
+ */
226
+ setAuthToken(token) {
227
+ this.authToken = token;
228
+ }
229
+ /**
230
+ * Set connection key for socket connection
231
+ */
232
+ setConnectionKey(key) {
233
+ this.connectionKey = key;
234
+ }
235
+ /**
236
+ * Reset connection with new token
237
+ */
238
+ resetWithNewToken(token) {
239
+ if (token) {
240
+ this.authToken = token;
241
+ }
242
+ if (this.socket) {
243
+ this.socket.disconnect();
244
+ }
245
+ this.setupSocketConnection();
246
+ }
247
+ connect() {
248
+ if (!this.socket.connected) {
249
+ this.socket.connect();
250
+ }
251
+ }
252
+ disconnect() {
253
+ if (this.socket.connected) {
254
+ this.socket.disconnect();
255
+ }
256
+ }
257
+ /**
258
+ * Emit event with optional authentication headers
259
+ */
260
+ emit(event, data) {
261
+ if (!this.socket || this.socket.disconnected) {
262
+ console.warn('Socket not connected. Call connect() first.');
263
+ return;
264
+ }
265
+ // If auth token or connection key exists, wrap data with headers
266
+ if (this.authToken || this.connectionKey) {
267
+ const payload = {
268
+ payload: data || {},
269
+ headers: {
270
+ ...(this.authToken && { _authToken: this.authToken }),
271
+ ...(this.connectionKey && { connectionKey: this.connectionKey })
272
+ }
273
+ };
274
+ this.socket.emit(event, payload);
275
+ }
276
+ else {
277
+ this.socket.emit(event, data);
278
+ }
279
+ }
280
+ /**
281
+ * Listen to events with persistent subjects that survive reconnections
282
+ */
283
+ on(event) {
284
+ if (!this.eventSubjects.has(event)) {
285
+ const subject = new Subject();
286
+ this.eventSubjects.set(event, subject);
287
+ // Set up initial listener if socket is connected
288
+ if (this.socket && this.socket.connected) {
289
+ this.socket.on(event, (data) => {
290
+ subject.next(data);
291
+ });
292
+ }
293
+ }
294
+ return this.eventSubjects.get(event).asObservable();
295
+ }
296
+ /**
297
+ * Listen to event once and return as Promise
298
+ */
299
+ once(event) {
300
+ if (!this.socket || this.socket.disconnected) {
301
+ return Promise.reject(new Error('Socket not connected. Call connect() first.'));
302
+ }
303
+ return new Promise((resolve) => {
304
+ this.socket.once(event, (data) => {
305
+ resolve(data);
306
+ });
307
+ });
308
+ }
309
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: SocketService, deps: [{ token: REALTIME_STORE_ENVIRONMENT }], target: i0.ɵɵFactoryTarget.Injectable });
310
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: SocketService });
311
+ }
312
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: SocketService, decorators: [{
313
+ type: Injectable
314
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
315
+ type: Inject,
316
+ args: [REALTIME_STORE_ENVIRONMENT]
317
+ }] }] });
318
+
319
+ class BaseStore {
320
+ socketService;
321
+ dataSubject = new BehaviorSubject([]);
322
+ data$ = this.dataSubject.asObservable();
323
+ loadingSubject = new BehaviorSubject(false);
324
+ loading$ = this.loadingSubject.asObservable();
325
+ errorSubject = new BehaviorSubject(null);
326
+ error$ = this.errorSubject.asObservable();
327
+ constructor(socketService) {
328
+ this.socketService = socketService;
329
+ Promise.resolve().then(() => this.refresh());
330
+ this.socketService.reconnect$.subscribe(() => {
331
+ this.refresh();
332
+ });
333
+ }
334
+ refresh() {
335
+ this.preload().then(x => this.dataSubject.next(x));
336
+ }
337
+ // Helper methods for stores
338
+ updateItems(items) {
339
+ console.log('setting', items);
340
+ this.dataSubject.next(items);
341
+ }
342
+ addItem(item) {
343
+ console.log('adding', item);
344
+ const currentItems = this.dataSubject.value;
345
+ this.dataSubject.next([...currentItems, item]);
346
+ }
347
+ updateItem(updatedItem, idField) {
348
+ console.log('updating', updatedItem);
349
+ const currentItems = this.dataSubject.value;
350
+ const updatedItems = currentItems.map(item => item[idField] === updatedItem[idField]
351
+ ? { ...item, ...updatedItem }
352
+ : item);
353
+ this.dataSubject.next(updatedItems);
354
+ }
355
+ removeItem(id, idField) {
356
+ console.log('removing', id);
357
+ const currentItems = this.dataSubject.value;
358
+ const filteredItems = currentItems.filter(item => item[idField] !== id);
359
+ this.dataSubject.next(filteredItems);
360
+ }
361
+ setLoading(isLoading) {
362
+ this.loadingSubject.next(isLoading);
363
+ }
364
+ setError(error) {
365
+ this.errorSubject.next(error);
366
+ }
367
+ // Helper to subscribe to socket events with typesafety
368
+ subscribeToEvent(event, handler) {
369
+ this.socketService.on(event).subscribe(handler);
370
+ }
371
+ getAll() {
372
+ return this.dataSubject.value;
373
+ }
374
+ getById(id, idField) {
375
+ return this.dataSubject.value.find(item => item[idField] === id);
376
+ }
377
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: BaseStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
378
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: BaseStore });
379
+ }
380
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: BaseStore, decorators: [{
381
+ type: Injectable
382
+ }], ctorParameters: () => [{ type: SocketService }] });
383
+
384
+ class TableStore extends BaseStore {
385
+ socketService = inject(SocketService);
386
+ constructor() {
387
+ const socketService = inject(SocketService);
388
+ super(socketService);
389
+ this.subscribeToEvent(SocketSuccessEvents.TABLE_CREATED, (table) => this.addItem(table));
390
+ this.subscribeToEvent(SocketSuccessEvents.TABLE_ASSIGNED, (table) => this.updateItem(table, 'id'));
391
+ this.subscribeToEvent(SocketSuccessEvents.TABLE_STATUS_UPDATED, (table) => this.updateItem(table, 'id'));
392
+ this.subscribeToEvent(SocketSuccessEvents.TABLE_RELEASED, (table) => this.updateItem(table, 'id'));
393
+ }
394
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
395
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStore });
396
+ }
397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStore, decorators: [{
398
+ type: Injectable
399
+ }], ctorParameters: () => [] });
400
+
401
+ class CartStore extends BaseStore {
402
+ socketService;
403
+ constructor(socketService) {
404
+ super(socketService);
405
+ this.socketService = socketService;
406
+ // Subscribe to cart socket events
407
+ this.subscribeToEvent(SocketSuccessEvents.CUSTOMER_CREATE_OR_UPDATE_CART_SUCCESS, (cart) => this.updateItem(cart, 'id'));
408
+ this.subscribeToEvent(SocketSuccessEvents.CUSTOMER_REMOVE_FROM_CART_SUCCESS, (data) => {
409
+ this.removeItem(data.cartId, 'id');
410
+ });
411
+ }
412
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CartStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
413
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CartStore });
414
+ }
415
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CartStore, decorators: [{
416
+ type: Injectable
417
+ }], ctorParameters: () => [{ type: SocketService }] });
418
+
419
+ class MenuStore extends BaseStore {
420
+ socketService;
421
+ constructor(socketService) {
422
+ super(socketService);
423
+ this.socketService = socketService;
424
+ // Subscribe to menu socket events
425
+ this.subscribeToEvent(SocketSuccessEvents.CUSTOMER_GET_MENU_SUCCESS, (menuItems) => this.updateItems(menuItems));
426
+ }
427
+ async getMenu(branchId) {
428
+ this.socketService.emit(SocketEvents.CUSTOMER_GET_MENU, { branchId });
429
+ }
430
+ async getMenuItemReviews(menuItemId) {
431
+ this.socketService.emit(SocketEvents.CUSTOMER_GET_MENU_ITEM_REVIEWS, { menuItemId });
432
+ }
433
+ async createMenuItemReview(menuItemId, rating, comment) {
434
+ this.socketService.emit(SocketEvents.CUSTOMER_CREATE_MENU_ITEM_REVIEW, {
435
+ menuItemId,
436
+ rating,
437
+ comment
438
+ });
439
+ }
440
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: MenuStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
441
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: MenuStore });
442
+ }
443
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: MenuStore, decorators: [{
444
+ type: Injectable
445
+ }], ctorParameters: () => [{ type: SocketService }] });
446
+
447
+ class CallWaiterStore extends BaseStore {
448
+ socketService;
449
+ constructor(socketService) {
450
+ super(socketService);
451
+ this.socketService = socketService;
452
+ // We need to listen for incoming waiter calls
453
+ this.socketService.on(SocketSuccessEvents.WAITER_RECEIVE_CALL).subscribe((request) => {
454
+ this.addItem(request);
455
+ });
456
+ }
457
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CallWaiterStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
458
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CallWaiterStore });
459
+ }
460
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CallWaiterStore, decorators: [{
461
+ type: Injectable
462
+ }], ctorParameters: () => [{ type: SocketService }] });
463
+
464
+ class CustomerLoginStore extends BaseStore {
465
+ socketService;
466
+ constructor(socketService) {
467
+ super(socketService);
468
+ this.socketService = socketService;
469
+ this.subscribeToEvent(SocketSuccessEvents.GET_PENDING_CUSTOMER_LOGINS_SUCCESS, (logins) => this.updateItems(logins));
470
+ }
471
+ getPendingLogins() {
472
+ this.socketService.emit(SocketEvents.GET_PENDING_CUSTOMER_LOGINS);
473
+ }
474
+ async approveCustomerLogin(customerId, tableId, customerAuthControllerApproveCustomerLogin) {
475
+ const approveData = {
476
+ customerId,
477
+ tableId
478
+ };
479
+ try {
480
+ await firstValueFrom(customerAuthControllerApproveCustomerLogin(approveData));
481
+ this.removeItem(customerId, 'id');
482
+ }
483
+ catch (error) {
484
+ console.error(`Failed to approve customer login for ${customerId}:`, error);
485
+ this.setError(`Failed to approve customer login`);
486
+ }
487
+ }
488
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CustomerLoginStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
489
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CustomerLoginStore });
490
+ }
491
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CustomerLoginStore, decorators: [{
492
+ type: Injectable
493
+ }], ctorParameters: () => [{ type: SocketService }] });
494
+
495
+ /**
496
+ * Provides all services needed for the realtime store to function.
497
+ * Use this function in your standalone application's bootstrapApplication providers array.
498
+ *
499
+ * @example
500
+ * ```typescript
501
+ * bootstrapApplication(AppComponent, {
502
+ * providers: [
503
+ * provideRealtimeStore()
504
+ * ]
505
+ * });
506
+ * ```
507
+ */
508
+ function provideRealtimeStore() {
509
+ return [
510
+ provideHttpClient(withInterceptorsFromDi())
511
+ ];
512
+ }
513
+
514
+ function provideRealtimeStoreEnvironment(environment) {
515
+ return {
516
+ provide: REALTIME_STORE_ENVIRONMENT,
517
+ useValue: environment
518
+ };
519
+ }
520
+
521
+ /*
522
+ * Public API Surface of realtime-store
523
+ */
524
+
525
+ /**
526
+ * Generated bundle index. Do not edit.
527
+ */
528
+
529
+ export { BaseStore, CallWaiterStore, CartStore, CustomerLoginStore, MenuStore, REALTIME_STORE_ENVIRONMENT, RealtimeStoreModule, SocketEvents, SocketService, SocketSuccessEvents, TableStore, defaultRealtimeStoreEnvironment, provideRealtimeStore, provideRealtimeStoreEnvironment };
530
+ //# sourceMappingURL=serve-socket.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serve-socket.mjs","sources":["../../../projects/serve-socket/src/lib/realtime-store.module.ts","../../../projects/serve-socket/src/lib/environment/realtime-store-environment.interface.ts","../../../projects/serve-socket/src/lib/environment/realtime-store-environment.token.ts","../../../projects/serve-socket/src/lib/model/socketGateways.ts","../../../projects/serve-socket/src/lib/socket.service.ts","../../../projects/serve-socket/src/lib/base-store.ts","../../../projects/serve-socket/src/lib/stores/table.store.ts","../../../projects/serve-socket/src/lib/stores/cart.store.ts","../../../projects/serve-socket/src/lib/stores/menu.store.ts","../../../projects/serve-socket/src/lib/stores/call-waiter.store.ts","../../../projects/serve-socket/src/lib/stores/customer-login.store.ts","../../../projects/serve-socket/src/lib/providers.ts","../../../projects/serve-socket/src/lib/providers/realtime-store-environment.provider.ts","../../../projects/serve-socket/src/public-api.ts","../../../projects/serve-socket/src/serve-socket.ts"],"sourcesContent":["import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\n\n/**\n * @deprecated Use provideRealtimeStore() with standalone components instead\n */\n@NgModule({\n declarations: [],\n imports: [\n CommonModule,\n HttpClientModule // Kept for backward compatibility with Angular <14\n ],\n exports: []\n})\nexport class RealtimeStoreModule { }\n","export interface RealtimeStoreEnvironment {\n apiUrl: string;\n}\n\nexport const defaultRealtimeStoreEnvironment: RealtimeStoreEnvironment = {\n // apiUrl: `http://${window.location.hostname}:3030`,\n apiUrl: `http://${window.location.hostname}:3030`,\n};","import { InjectionToken } from '@angular/core';\nimport { RealtimeStoreEnvironment } from './realtime-store-environment.interface';\n\nexport const REALTIME_STORE_ENVIRONMENT = new InjectionToken<RealtimeStoreEnvironment>('REALTIME_STORE_ENVIRONMENT');","/**\n * API Gateway\n *\n * \n *\n * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).\n * https://openapi-generator.tech\n * Do not edit the class manually.\n */\n\n\nexport interface SocketGateways { \n /**\n * All possible socket success events emitted by the server\n */\n response: SocketGateways.ResponseEnum;\n /**\n * Auth message patterns for the socket gateway\n */\n request: SocketGateways.RequestEnum;\n}\nexport namespace SocketGateways {\n export const ResponseEnum = {\n CustomerCreateCartSuccess: 'customer:create:cart:success',\n CustomerRemoveFromCartSuccess: 'customer:remove:from:cart:success',\n CustomerGetMenuSuccess: 'customer:get:menu:success',\n TableJoinRequestSuccess: 'table:join:request:success',\n TableJoinRequestApprovedSuccess: 'table:join:request:approved:success',\n ErrorMessageSuccess: 'error:message:success',\n SuccessMessageSuccess: 'success:message:success',\n WarningMessageSuccess: 'warning:message:success',\n AuthCustomerLoginPendingGetSuccess: 'auth:customer:login:pending:get:success',\n CustomerUpdateIsPaidSuccess: 'customer:update:is-paid:success',\n TableCreatedSuccess: 'table:created:success',\n TableAssignedSuccess: 'table:assigned:success',\n TableStatusUpdatedSuccess: 'table:status:updated:success',\n TableReleasedSuccess: 'table:released:success'\n } as const;\n export type ResponseEnum = typeof ResponseEnum[keyof typeof ResponseEnum];\n export const RequestEnum = {\n AuthCustomerLogin: 'auth:customer:login',\n AuthCustomerLoginReconnect: 'auth:customer:login:reconnect',\n PosLogin: 'pos:login',\n CustomerGetCart: 'customer:get:cart',\n CustomerGetOneCart: 'customer:get-one:cart',\n CustomerRemoveFromCart: 'customer:remove:from:cart',\n CustomerUpdateCart: 'customer:update:cart',\n GetCartByWaiter: 'get:cart:by:waiter',\n GetAllCarts: 'get:all:carts',\n CustomerGetMenu: 'customer:get:menu',\n ErrorMessage: 'error:message',\n SuccessMessage: 'success:message',\n JoinRoom: 'join:room',\n GetTheming: 'get:theming',\n CustomerCartItemStatusUpdate: 'customer:cart:item:status:update',\n CustomerGetMenuItemReviews: 'customer:get:menu-item:reviews',\n CustomerCreateMenuItemReview: 'customer:create:menu-item:review',\n CustomerGetRequestsByTable: 'customer:get:requests:by:table',\n WaiterGetRequestsByTable: 'waiter:get:requests:by:table',\n CustomerCallWaiter: 'customer:call:waiter',\n WaiterReceiveCall: 'waiter:receive:call',\n WaiterCallAcknowledged: 'waiter:call:acknowledged',\n CustomerGetCallWaiterRequests: 'customer:get:call:waiter:requests',\n WaiterGetCalls: 'waiter:get:calls',\n WaiterGetAvailable: 'waiter:get:available',\n WaiterCallCreate: 'waiter:call:create',\n WaiterCallResolve: 'waiter:call:resolve',\n TableAssignToWaiter: 'table:assign:to:waiter',\n AuthCustomerLoginApprove: 'auth:customer:login:approve',\n AuthCustomerLoginPendingGet: 'auth:customer:login:pending:get',\n AuthCustomerApprovalPendingGetSuccess: 'auth:customer:approval:pending:get:success',\n AuthCustomerApprovalPendingGetForWaiter: 'auth:customer:approval:pending:get:for:waiter',\n PosLogin2: 'pos:login',\n PosValidateBranchCode: 'pos:validate:branch:code',\n PosWaiterLogin: 'pos:waiter:login',\n WaiterGetTables: 'waiter:get:tables',\n WaiterGetLoggedIn: 'waiter:get:logged:in',\n TableGetAll: 'table:get:all',\n TableCreate: 'table:create',\n TableAssign: 'table:assign',\n TableUpdateStatus: 'table:update:status',\n TableRelease: 'table:release',\n WaiterGetTablesDetails: 'waiter:get:tables:details',\n TableGetDetails: 'table:get:details',\n PosWaiterCreate: 'pos:waiter:create'\n } as const;\n export type RequestEnum = typeof RequestEnum[keyof typeof RequestEnum];\n}\n\n\n","import { Injectable, Inject } from '@angular/core';\nimport { BehaviorSubject, Observable, Subject } from 'rxjs';\nimport { io, Socket } from 'socket.io-client';\n// import { SocketGateways } from '@serve-plus/client-api';\nimport { REALTIME_STORE_ENVIRONMENT, RealtimeStoreEnvironment, defaultRealtimeStoreEnvironment } from './environment';\nimport { SocketGateways } from './model/socketGateways';\n\n// Define string constants instead of enum to avoid type errors with string values\nexport const SocketEvents = {\n CUSTOMER_CONNECT: SocketGateways.RequestEnum.AuthCustomerLogin,\n CUSTOMER_RECONNECT: SocketGateways.RequestEnum.AuthCustomerLoginReconnect,\n CUSTOMER_GET_CART: SocketGateways.RequestEnum.CustomerGetCart,\n CUSTOMER_GET_ONE_CART: SocketGateways.RequestEnum.CustomerGetOneCart,\n CUSTOMER_REMOVE_FROM_CART: SocketGateways.RequestEnum.CustomerRemoveFromCart,\n CUSTOMER_CREATE_UPDATE_CART: SocketGateways.RequestEnum.CustomerUpdateCart,\n CUSTOMER_GET_MENU: SocketGateways.RequestEnum.CustomerGetMenu,\n ERROR_MESSAGE: SocketGateways.RequestEnum.ErrorMessage,\n SUCCESS_MESSAGE: SocketGateways.RequestEnum.SuccessMessage,\n JOIN_ROOM: SocketGateways.RequestEnum.JoinRoom,\n GET_THEMING: SocketGateways.RequestEnum.GetTheming,\n CUSTOMER_CART_ITEM_STATUS_UPDATE: SocketGateways.RequestEnum.CustomerCartItemStatusUpdate,\n CUSTOMER_GET_MENU_ITEM_REVIEWS: SocketGateways.RequestEnum.CustomerGetMenuItemReviews,\n CUSTOMER_CREATE_MENU_ITEM_REVIEW: SocketGateways.RequestEnum.CustomerCreateMenuItemReview,\n CUSTOMER_GET_REQUESTS_BY_TABLE: SocketGateways.RequestEnum.CustomerGetRequestsByTable,\n WAITER_GET_REQUESTS_BY_TABLE: SocketGateways.RequestEnum.WaiterGetRequestsByTable,\n CUSTOMER_CALL_WAITER: SocketGateways.RequestEnum.CustomerCallWaiter,\n WAITER_RECEIVE_CALL: SocketGateways.RequestEnum.WaiterReceiveCall,\n WAITER_CALL_ACKNOWLEDGED: SocketGateways.RequestEnum.WaiterCallAcknowledged,\n CUSTOMER_GET_CALL_WAITER_REQUESTS: SocketGateways.RequestEnum.CustomerGetCallWaiterRequests,\n APPROVE_CUSTOMER_LOGIN: SocketGateways.RequestEnum.AuthCustomerLoginApprove,\n GET_PENDING_CUSTOMER_LOGINS: SocketGateways.RequestEnum.AuthCustomerLoginPendingGet,\n POS_LOGIN: SocketGateways.RequestEnum.PosLogin,\n GET_ALL_TABLES: SocketGateways.RequestEnum.TableGetAll,\n CREATE_TABLE: SocketGateways.RequestEnum.TableCreate,\n ASSIGN_TABLE: SocketGateways.RequestEnum.TableAssign,\n UPDATE_TABLE_STATUS: SocketGateways.RequestEnum.TableUpdateStatus,\n RELEASE_TABLE: SocketGateways.RequestEnum.TableRelease\n};\n\nexport const SocketSuccessEvents = {\n // Map to SocketGateways.ResponseEnum\n CUSTOMER_CREATE_OR_UPDATE_CART_SUCCESS: SocketGateways.ResponseEnum.CustomerCreateCartSuccess,\n CUSTOMER_REMOVE_FROM_CART_SUCCESS: SocketGateways.ResponseEnum.CustomerRemoveFromCartSuccess,\n CUSTOMER_GET_MENU_SUCCESS: SocketGateways.ResponseEnum.CustomerGetMenuSuccess,\n TABLE_JOIN_REQUEST_SENT_SUCCESS: SocketGateways.ResponseEnum.TableJoinRequestSuccess,\n TABLE_JOIN_REQUEST_APPROVED_SUCCESS: SocketGateways.ResponseEnum.TableJoinRequestApprovedSuccess,\n ERROR_MESSAGE_SUCCESS: SocketGateways.ResponseEnum.ErrorMessageSuccess,\n SUCCESS_MESSAGE_SUCCESS: SocketGateways.ResponseEnum.SuccessMessageSuccess,\n WARNING_MESSAGE_SUCCESS: SocketGateways.ResponseEnum.WarningMessageSuccess,\n GET_PENDING_CUSTOMER_LOGINS_SUCCESS: SocketGateways.ResponseEnum.AuthCustomerLoginPendingGetSuccess,\n CUSTOMER_UPDATE_IS_PAID_SUCCESS: SocketGateways.ResponseEnum.CustomerUpdateIsPaidSuccess,\n TABLE_CREATED: SocketGateways.ResponseEnum.TableCreatedSuccess,\n TABLE_ASSIGNED: SocketGateways.ResponseEnum.TableAssignedSuccess,\n TABLE_STATUS_UPDATED: SocketGateways.ResponseEnum.TableStatusUpdatedSuccess,\n TABLE_RELEASED: SocketGateways.ResponseEnum.TableReleasedSuccess,\n\n // Add WAITER_RECEIVE_CALL which appears to be missing from the ResponseEnum\n WAITER_RECEIVE_CALL: 'waiter:receive:call'\n};\n\n\n@Injectable()\nexport class SocketService {\n private socket!: Socket;\n private url: string;\n private authToken?: string;\n private connectionKey?: string;\n private eventSubjects = new Map<string, Subject<any>>();\n\n private connectionStatusSubject = new BehaviorSubject<boolean>(false);\n public connectionStatus$ = this.connectionStatusSubject.asObservable();\n\n private reconnectSubject = new Subject<void>();\n public reconnect$ = this.reconnectSubject.asObservable();\n\n constructor(\n @Inject(REALTIME_STORE_ENVIRONMENT) private environment: RealtimeStoreEnvironment = defaultRealtimeStoreEnvironment\n ) {\n this.url = this.environment.apiUrl;\n this.setupSocketConnection();\n }\n\n private setupSocketConnection(): void {\n const socketOptions: any = {\n transports: ['websocket'],\n autoConnect: true\n };\n\n // Add auth if token is available\n if (this.authToken) {\n socketOptions.auth = {\n token: this.authToken\n };\n }\n\n this.socket = io(this.url, socketOptions);\n\n this.socket.on('connect', () => {\n console.log('Socket connected');\n this.connectionStatusSubject.next(true);\n this.reestablishListeners();\n });\n\n this.socket.on('disconnect', () => {\n console.log('Socket disconnected');\n this.connectionStatusSubject.next(false);\n });\n\n this.socket.on('reconnect', () => {\n console.log('Socket reconnected');\n this.connectionStatusSubject.next(true);\n this.reconnectSubject.next();\n this.reestablishListeners();\n });\n\n this.socket.on('connect_error', (err) => {\n console.error('Connection error:', err.message);\n });\n\n this.socket.on('reconnect_error', (err) => {\n console.error('Reconnection error:', err.message);\n });\n }\n\n private reestablishListeners(): void {\n console.log('Re-establishing listeners for', this.eventSubjects.size, 'events');\n this.eventSubjects.forEach((subject, eventName) => {\n this.socket.on(eventName, (data) => {\n subject.next(data);\n });\n });\n }\n\n /**\n * Set authentication token for socket connection\n */\n public setAuthToken(token: string): void {\n this.authToken = token;\n }\n\n /**\n * Set connection key for socket connection\n */\n public setConnectionKey(key: string): void {\n this.connectionKey = key;\n }\n\n /**\n * Reset connection with new token\n */\n public resetWithNewToken(token?: string): void {\n if (token) {\n this.authToken = token;\n }\n\n if (this.socket) {\n this.socket.disconnect();\n }\n\n this.setupSocketConnection();\n }\n\n public connect(): void {\n if (!this.socket.connected) {\n this.socket.connect();\n }\n }\n\n public disconnect(): void {\n if (this.socket.connected) {\n this.socket.disconnect();\n }\n }\n\n /**\n * Emit event with optional authentication headers\n */\n public emit(event: string, data?: any): void {\n if (!this.socket || this.socket.disconnected) {\n console.warn('Socket not connected. Call connect() first.');\n return;\n }\n\n // If auth token or connection key exists, wrap data with headers\n if (this.authToken || this.connectionKey) {\n const payload = {\n payload: data || {},\n headers: {\n ...(this.authToken && { _authToken: this.authToken }),\n ...(this.connectionKey && { connectionKey: this.connectionKey })\n }\n };\n this.socket.emit(event, payload);\n } else {\n this.socket.emit(event, data);\n }\n }\n\n /**\n * Listen to events with persistent subjects that survive reconnections\n */\n public on<T>(event: string): Observable<T> {\n if (!this.eventSubjects.has(event)) {\n const subject = new Subject<T>();\n this.eventSubjects.set(event, subject);\n\n // Set up initial listener if socket is connected\n if (this.socket && this.socket.connected) {\n this.socket.on(event, (data: T) => {\n subject.next(data);\n });\n }\n }\n\n return this.eventSubjects.get(event)!.asObservable();\n }\n\n /**\n * Listen to event once and return as Promise\n */\n public once<T>(event: string): Promise<T> {\n if (!this.socket || this.socket.disconnected) {\n return Promise.reject(new Error('Socket not connected. Call connect() first.'));\n }\n\n return new Promise((resolve) => {\n this.socket.once(event, (data: T) => {\n resolve(data);\n });\n });\n }\n}\n\n","import { BehaviorSubject, Observable } from 'rxjs';\nimport { SocketService } from './socket.service';\nimport { Injectable } from '@angular/core';\n\n@Injectable()\nexport abstract class BaseStore<T> {\n protected dataSubject = new BehaviorSubject<T[]>([]);\n public data$: Observable<T[]> = this.dataSubject.asObservable();\n\n protected loadingSubject = new BehaviorSubject<boolean>(false);\n public loading$: Observable<boolean> = this.loadingSubject.asObservable();\n\n protected errorSubject = new BehaviorSubject<string | null>(null);\n public error$: Observable<string | null> = this.errorSubject.asObservable();\n\n constructor(\n protected socketService: SocketService\n ) {\n Promise.resolve().then(() => this.refresh());\n\n this.socketService.reconnect$.subscribe(() => {\n this.refresh();\n });\n }\n\n private refresh() {\n this.preload().then(x => this.dataSubject.next(x));\n }\n\n // Abstract methods to be implemented by specific stores\n public abstract preload(): Promise<T[]>;\n\n // Helper methods for stores\n protected updateItems(items: T[]): void {\n console.log('setting', items);\n\n this.dataSubject.next(items);\n }\n\n protected addItem(item: T): void {\n console.log('adding', item);\n const currentItems = this.dataSubject.value;\n this.dataSubject.next([...currentItems, item]);\n }\n\n protected updateItem(updatedItem: Partial<T>, idField: keyof T): void {\n console.log('updating', updatedItem);\n\n const currentItems = this.dataSubject.value;\n const updatedItems = currentItems.map(item =>\n item[idField] === updatedItem[idField]\n ? { ...item, ...updatedItem }\n : item\n );\n this.dataSubject.next(updatedItems);\n }\n\n protected removeItem(id: any, idField: keyof T): void {\n console.log('removing', id);\n\n const currentItems = this.dataSubject.value;\n const filteredItems = currentItems.filter(item => item[idField] !== id);\n this.dataSubject.next(filteredItems);\n }\n\n protected setLoading(isLoading: boolean): void {\n this.loadingSubject.next(isLoading);\n }\n\n protected setError(error: string | null): void {\n this.errorSubject.next(error);\n }\n\n // Helper to subscribe to socket events with typesafety\n protected subscribeToEvent<R>(\n event: string,\n handler: (data: R) => void\n ): void {\n this.socketService.on<R>(event).subscribe(handler);\n }\n\n getAll(): T[] {\n return this.dataSubject.value;\n }\n\n getById(id: any, idField: keyof T): T | undefined {\n return this.dataSubject.value.find(item => item[idField] === id);\n }\n}\n","import { Injectable, inject } from '@angular/core';\nimport { BaseStore } from '../base-store';\nimport { SocketService } from '../socket.service';\nimport { SocketSuccessEvents } from '../socket.service';\nimport { TableResponseDto } from '../model/tableResponseDto';\n\n@Injectable()\nexport abstract class TableStore extends BaseStore<TableResponseDto> {\n protected override socketService = inject(SocketService);\n\n constructor() {\n const socketService = inject(SocketService);\n super(socketService);\n\n this.subscribeToEvent<TableResponseDto>(\n SocketSuccessEvents.TABLE_CREATED,\n (table) => this.addItem(table)\n );\n\n this.subscribeToEvent<TableResponseDto>(\n SocketSuccessEvents.TABLE_ASSIGNED,\n (table) => this.updateItem(table, 'id')\n );\n\n this.subscribeToEvent<TableResponseDto>(\n SocketSuccessEvents.TABLE_STATUS_UPDATED,\n (table) => this.updateItem(table, 'id')\n );\n\n this.subscribeToEvent<TableResponseDto>(\n SocketSuccessEvents.TABLE_RELEASED,\n (table) => this.updateItem(table, 'id')\n );\n }\n\n public abstract override preload(): Promise<TableResponseDto[]>;\n}\n","import { Injectable } from '@angular/core';\nimport { BaseStore } from '../base-store';\nimport { SocketService } from '../socket.service';\nimport { SocketSuccessEvents } from '../socket.service';\nimport { CartDto } from '../model/cartDto';\n\n@Injectable()\nexport abstract class CartStore extends BaseStore<CartDto> {\n constructor(\n protected override socketService: SocketService\n ) {\n super(socketService);\n\n // Subscribe to cart socket events\n this.subscribeToEvent<CartDto>(\n SocketSuccessEvents.CUSTOMER_CREATE_OR_UPDATE_CART_SUCCESS,\n (cart) => this.updateItem(cart, 'id')\n );\n\n this.subscribeToEvent<{ cartId: string, itemId: string }>(\n SocketSuccessEvents.CUSTOMER_REMOVE_FROM_CART_SUCCESS,\n (data) => {\n this.removeItem(data.cartId, 'id');\n }\n );\n }\n}\n","import { Injectable } from '@angular/core';\nimport { firstValueFrom } from 'rxjs';\nimport { BaseStore } from '../base-store';\nimport { SocketService } from '../socket.service';\nimport { SocketEvents, SocketSuccessEvents } from '../socket.service';\nimport { MenuItemDto } from '../model/menuItemDto';\n\n@Injectable()\nexport abstract class MenuStore extends BaseStore<MenuItemDto> {\n constructor(\n protected override socketService: SocketService\n ) {\n super(socketService);\n\n // Subscribe to menu socket events\n this.subscribeToEvent<MenuItemDto[]>(\n SocketSuccessEvents.CUSTOMER_GET_MENU_SUCCESS,\n (menuItems) => this.updateItems(menuItems)\n );\n }\n\n public async getMenu(branchId: string): Promise<void> {\n this.socketService.emit(SocketEvents.CUSTOMER_GET_MENU, { branchId });\n }\n\n public async getMenuItemReviews(menuItemId: string): Promise<void> {\n this.socketService.emit(SocketEvents.CUSTOMER_GET_MENU_ITEM_REVIEWS, { menuItemId });\n }\n\n public async createMenuItemReview(menuItemId: string, rating: number, comment: string): Promise<void> {\n this.socketService.emit(SocketEvents.CUSTOMER_CREATE_MENU_ITEM_REVIEW, {\n menuItemId,\n rating,\n comment\n });\n }\n}\n","import { Injectable } from '@angular/core';\nimport { BaseStore } from '../base-store';\nimport { SocketService } from '../socket.service';\nimport { SocketSuccessEvents } from '../socket.service';\nimport { WaiterCallResponseDto } from '../model/waiterCallResponseDto';\n\n@Injectable()\nexport abstract class CallWaiterStore extends BaseStore<WaiterCallResponseDto> {\n constructor(\n protected override socketService: SocketService\n ) {\n super(socketService);\n\n // We need to listen for incoming waiter calls\n this.socketService.on<WaiterCallResponseDto>(\n SocketSuccessEvents.WAITER_RECEIVE_CALL\n ).subscribe((request: WaiterCallResponseDto) => {\n this.addItem(request);\n });\n }\n\n public abstract override preload(): Promise<WaiterCallResponseDto[]>;\n}\n","import { Injectable } from '@angular/core';\nimport { firstValueFrom, Observable } from 'rxjs';\nimport { BaseStore } from '../base-store';\nimport { SocketService } from '../socket.service';\nimport { SocketEvents, SocketSuccessEvents } from '../socket.service';\nimport { CustomerAuthControllerApproveCustomerLoginRequest } from '../model/customerAuthControllerApproveCustomerLoginRequest';\nimport { CustomerLoginRequestDto } from '../model/customerLoginRequestDto';\n\n@Injectable()\nexport abstract class CustomerLoginStore extends BaseStore<CustomerLoginRequestDto> {\n constructor(\n protected override socketService: SocketService\n ) {\n super(socketService);\n this.subscribeToEvent<CustomerLoginRequestDto[]>(\n SocketSuccessEvents.GET_PENDING_CUSTOMER_LOGINS_SUCCESS,\n (logins) => this.updateItems(logins)\n );\n }\n\n public getPendingLogins(): void {\n this.socketService.emit(SocketEvents.GET_PENDING_CUSTOMER_LOGINS);\n }\n\n public async approveCustomerLogin(customerId: string,\n tableId: string,\n customerAuthControllerApproveCustomerLogin: (payload: CustomerAuthControllerApproveCustomerLoginRequest)\n => Observable<CustomerAuthControllerApproveCustomerLoginRequest>\n ): Promise<void> {\n const approveData: CustomerAuthControllerApproveCustomerLoginRequest = {\n customerId,\n tableId\n };\n\n try {\n await firstValueFrom(\n customerAuthControllerApproveCustomerLogin(approveData)\n );\n\n this.removeItem(customerId, 'id');\n } catch (error) {\n console.error(`Failed to approve customer login for ${customerId}:`, error);\n this.setError(`Failed to approve customer login`);\n }\n }\n}\n","import { EnvironmentProviders, importProvidersFrom } from '@angular/core';\nimport { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';\n\n/**\n * Provides all services needed for the realtime store to function.\n * Use this function in your standalone application's bootstrapApplication providers array.\n * \n * @example\n * ```typescript\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideRealtimeStore()\n * ]\n * });\n * ```\n */\nexport function provideRealtimeStore(): EnvironmentProviders[] {\n return [\n provideHttpClient(withInterceptorsFromDi())\n ];\n}\n","import { Provider } from '@angular/core';\nimport { REALTIME_STORE_ENVIRONMENT, RealtimeStoreEnvironment } from '../environment';\n\nexport function provideRealtimeStoreEnvironment(environment: RealtimeStoreEnvironment): Provider {\n return {\n provide: REALTIME_STORE_ENVIRONMENT,\n useValue: environment\n };\n}","/*\n * Public API Surface of realtime-store\n */\n\nexport * from './lib/realtime-store.module';\nexport * from './lib/socket.service';\nexport * from './lib/base-store';\nexport * from './lib/stores/table.store';\nexport * from './lib/stores/cart.store';\nexport * from './lib/stores/menu.store';\nexport * from './lib/stores/call-waiter.store';\nexport * from './lib/stores/customer-login.store';\nexport * from './lib/providers';\nexport * from './lib/environment';\nexport * from './lib/providers/realtime-store-environment.provider';\nexport * from './lib/model/waiterCallResponseDto';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["i1.SocketService"],"mappings":";;;;;;;AAIA;;AAEG;MASU,mBAAmB,CAAA;wGAAnB,mBAAmB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA;AAAnB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,mBAAmB,YALxB,YAAY;AACZ,YAAA,gBAAgB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AA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;4GAAlB,kBAAkB,EAAA,CAAA;;4FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBADvC;;;ACLD;;;;;;;;;;;;AAYG;SACa,oBAAoB,GAAA;IAChC,OAAO;QACH,iBAAiB,CAAC,sBAAsB,EAAE;KAC7C;AACL;;ACjBM,SAAU,+BAA+B,CAAC,WAAqC,EAAA;IACjF,OAAO;AACH,QAAA,OAAO,EAAE,0BAA0B;AACnC,QAAA,QAAQ,EAAE;KACb;AACL;;ACRA;;AAEG;;ACFH;;AAEG;;;;"}
package/index.d.ts ADDED
@@ -0,0 +1,675 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, EnvironmentProviders, Provider } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import * as i2 from '@angular/common/http';
5
+ import { Observable, BehaviorSubject } from 'rxjs';
6
+
7
+ /**
8
+ * @deprecated Use provideRealtimeStore() with standalone components instead
9
+ */
10
+ declare class RealtimeStoreModule {
11
+ static ɵfac: i0.ɵɵFactoryDeclaration<RealtimeStoreModule, never>;
12
+ static ɵmod: i0.ɵɵNgModuleDeclaration<RealtimeStoreModule, never, [typeof i1.CommonModule, typeof i2.HttpClientModule], never>;
13
+ static ɵinj: i0.ɵɵInjectorDeclaration<RealtimeStoreModule>;
14
+ }
15
+
16
+ interface RealtimeStoreEnvironment {
17
+ apiUrl: string;
18
+ }
19
+ declare const defaultRealtimeStoreEnvironment: RealtimeStoreEnvironment;
20
+
21
+ declare const REALTIME_STORE_ENVIRONMENT: InjectionToken<RealtimeStoreEnvironment>;
22
+
23
+ declare const SocketEvents: {
24
+ CUSTOMER_CONNECT: "auth:customer:login";
25
+ CUSTOMER_RECONNECT: "auth:customer:login:reconnect";
26
+ CUSTOMER_GET_CART: "customer:get:cart";
27
+ CUSTOMER_GET_ONE_CART: "customer:get-one:cart";
28
+ CUSTOMER_REMOVE_FROM_CART: "customer:remove:from:cart";
29
+ CUSTOMER_CREATE_UPDATE_CART: "customer:update:cart";
30
+ CUSTOMER_GET_MENU: "customer:get:menu";
31
+ ERROR_MESSAGE: "error:message";
32
+ SUCCESS_MESSAGE: "success:message";
33
+ JOIN_ROOM: "join:room";
34
+ GET_THEMING: "get:theming";
35
+ CUSTOMER_CART_ITEM_STATUS_UPDATE: "customer:cart:item:status:update";
36
+ CUSTOMER_GET_MENU_ITEM_REVIEWS: "customer:get:menu-item:reviews";
37
+ CUSTOMER_CREATE_MENU_ITEM_REVIEW: "customer:create:menu-item:review";
38
+ CUSTOMER_GET_REQUESTS_BY_TABLE: "customer:get:requests:by:table";
39
+ WAITER_GET_REQUESTS_BY_TABLE: "waiter:get:requests:by:table";
40
+ CUSTOMER_CALL_WAITER: "customer:call:waiter";
41
+ WAITER_RECEIVE_CALL: "waiter:receive:call";
42
+ WAITER_CALL_ACKNOWLEDGED: "waiter:call:acknowledged";
43
+ CUSTOMER_GET_CALL_WAITER_REQUESTS: "customer:get:call:waiter:requests";
44
+ APPROVE_CUSTOMER_LOGIN: "auth:customer:login:approve";
45
+ GET_PENDING_CUSTOMER_LOGINS: "auth:customer:login:pending:get";
46
+ POS_LOGIN: "pos:login";
47
+ GET_ALL_TABLES: "table:get:all";
48
+ CREATE_TABLE: "table:create";
49
+ ASSIGN_TABLE: "table:assign";
50
+ UPDATE_TABLE_STATUS: "table:update:status";
51
+ RELEASE_TABLE: "table:release";
52
+ };
53
+ declare const SocketSuccessEvents: {
54
+ CUSTOMER_CREATE_OR_UPDATE_CART_SUCCESS: "customer:create:cart:success";
55
+ CUSTOMER_REMOVE_FROM_CART_SUCCESS: "customer:remove:from:cart:success";
56
+ CUSTOMER_GET_MENU_SUCCESS: "customer:get:menu:success";
57
+ TABLE_JOIN_REQUEST_SENT_SUCCESS: "table:join:request:success";
58
+ TABLE_JOIN_REQUEST_APPROVED_SUCCESS: "table:join:request:approved:success";
59
+ ERROR_MESSAGE_SUCCESS: "error:message:success";
60
+ SUCCESS_MESSAGE_SUCCESS: "success:message:success";
61
+ WARNING_MESSAGE_SUCCESS: "warning:message:success";
62
+ GET_PENDING_CUSTOMER_LOGINS_SUCCESS: "auth:customer:login:pending:get:success";
63
+ CUSTOMER_UPDATE_IS_PAID_SUCCESS: "customer:update:is-paid:success";
64
+ TABLE_CREATED: "table:created:success";
65
+ TABLE_ASSIGNED: "table:assigned:success";
66
+ TABLE_STATUS_UPDATED: "table:status:updated:success";
67
+ TABLE_RELEASED: "table:released:success";
68
+ WAITER_RECEIVE_CALL: string;
69
+ };
70
+ declare class SocketService {
71
+ private environment;
72
+ private socket;
73
+ private url;
74
+ private authToken?;
75
+ private connectionKey?;
76
+ private eventSubjects;
77
+ private connectionStatusSubject;
78
+ connectionStatus$: Observable<boolean>;
79
+ private reconnectSubject;
80
+ reconnect$: Observable<void>;
81
+ constructor(environment?: RealtimeStoreEnvironment);
82
+ private setupSocketConnection;
83
+ private reestablishListeners;
84
+ /**
85
+ * Set authentication token for socket connection
86
+ */
87
+ setAuthToken(token: string): void;
88
+ /**
89
+ * Set connection key for socket connection
90
+ */
91
+ setConnectionKey(key: string): void;
92
+ /**
93
+ * Reset connection with new token
94
+ */
95
+ resetWithNewToken(token?: string): void;
96
+ connect(): void;
97
+ disconnect(): void;
98
+ /**
99
+ * Emit event with optional authentication headers
100
+ */
101
+ emit(event: string, data?: any): void;
102
+ /**
103
+ * Listen to events with persistent subjects that survive reconnections
104
+ */
105
+ on<T>(event: string): Observable<T>;
106
+ /**
107
+ * Listen to event once and return as Promise
108
+ */
109
+ once<T>(event: string): Promise<T>;
110
+ static ɵfac: i0.ɵɵFactoryDeclaration<SocketService, never>;
111
+ static ɵprov: i0.ɵɵInjectableDeclaration<SocketService>;
112
+ }
113
+
114
+ declare abstract class BaseStore<T> {
115
+ protected socketService: SocketService;
116
+ protected dataSubject: BehaviorSubject<T[]>;
117
+ data$: Observable<T[]>;
118
+ protected loadingSubject: BehaviorSubject<boolean>;
119
+ loading$: Observable<boolean>;
120
+ protected errorSubject: BehaviorSubject<string | null>;
121
+ error$: Observable<string | null>;
122
+ constructor(socketService: SocketService);
123
+ private refresh;
124
+ abstract preload(): Promise<T[]>;
125
+ protected updateItems(items: T[]): void;
126
+ protected addItem(item: T): void;
127
+ protected updateItem(updatedItem: Partial<T>, idField: keyof T): void;
128
+ protected removeItem(id: any, idField: keyof T): void;
129
+ protected setLoading(isLoading: boolean): void;
130
+ protected setError(error: string | null): void;
131
+ protected subscribeToEvent<R>(event: string, handler: (data: R) => void): void;
132
+ getAll(): T[];
133
+ getById(id: any, idField: keyof T): T | undefined;
134
+ static ɵfac: i0.ɵɵFactoryDeclaration<BaseStore<any>, never>;
135
+ static ɵprov: i0.ɵɵInjectableDeclaration<BaseStore<any>>;
136
+ }
137
+
138
+ /**
139
+ * API Gateway
140
+ *
141
+ *
142
+ *
143
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
144
+ * https://openapi-generator.tech
145
+ * Do not edit the class manually.
146
+ */
147
+ interface WaiterDto {
148
+ /**
149
+ * Unique identifier of the waiter
150
+ */
151
+ id: string;
152
+ /**
153
+ * Name of the waiter
154
+ */
155
+ name: string;
156
+ /**
157
+ * Unique username for the waiter
158
+ */
159
+ username: string;
160
+ /**
161
+ * Encrypted password for the waiter
162
+ */
163
+ password?: string;
164
+ /**
165
+ * Socket key for real-time communication
166
+ */
167
+ socketKey?: string;
168
+ /**
169
+ * Tables assigned to this waiter
170
+ */
171
+ tables?: Array<string>;
172
+ }
173
+
174
+ /**
175
+ * API Gateway
176
+ *
177
+ *
178
+ *
179
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
180
+ * https://openapi-generator.tech
181
+ * Do not edit the class manually.
182
+ */
183
+ interface CallWaiterDtoCustomer {
184
+ id: string;
185
+ name: string;
186
+ verified: boolean;
187
+ isHost: boolean;
188
+ tableId: string;
189
+ }
190
+
191
+ /**
192
+ * API Gateway
193
+ *
194
+ *
195
+ *
196
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
197
+ * https://openapi-generator.tech
198
+ * Do not edit the class manually.
199
+ */
200
+
201
+ interface CallWaiterDto {
202
+ /**
203
+ * Unique identifier of the call waiter request
204
+ */
205
+ id: string;
206
+ /**
207
+ * ID of the customer making the waiter call
208
+ */
209
+ customerId: string;
210
+ /**
211
+ * Whether the waiter call has been resolved
212
+ */
213
+ isResolved: boolean;
214
+ /**
215
+ * Message or reason for calling the waiter
216
+ */
217
+ message?: string;
218
+ customer?: CallWaiterDtoCustomer;
219
+ }
220
+
221
+ /**
222
+ * API Gateway
223
+ *
224
+ *
225
+ *
226
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
227
+ * https://openapi-generator.tech
228
+ * Do not edit the class manually.
229
+ */
230
+
231
+ interface CartDto {
232
+ /**
233
+ * UUID of the cart
234
+ */
235
+ id?: string;
236
+ /**
237
+ * UUID of the table associated with this cart
238
+ */
239
+ tableId: string;
240
+ /**
241
+ * UUID of the menu item for this cart
242
+ */
243
+ menuItemId: string;
244
+ /**
245
+ * Customer cart items within this cart
246
+ */
247
+ customerCarts?: Array<CustomerCartDto>;
248
+ }
249
+
250
+ /**
251
+ * API Gateway
252
+ *
253
+ *
254
+ *
255
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
256
+ * https://openapi-generator.tech
257
+ * Do not edit the class manually.
258
+ */
259
+
260
+ interface CustomerCartDto {
261
+ /**
262
+ * UUID of the customer cart item
263
+ */
264
+ id?: string;
265
+ /**
266
+ * UUID of the customer placing the order
267
+ */
268
+ customerId: string;
269
+ /**
270
+ * Customer details
271
+ */
272
+ customer?: CustomerDto;
273
+ /**
274
+ * UUID of the main cart this item belongs to
275
+ */
276
+ cartItemId: string;
277
+ /**
278
+ * Cart item details
279
+ */
280
+ cartItem?: CartDto;
281
+ /**
282
+ * Quantity of the item ordered by this customer
283
+ */
284
+ quantity: number;
285
+ /**
286
+ * Current status of this customer\'s cart item
287
+ */
288
+ status?: CustomerCartDto.StatusEnum;
289
+ /**
290
+ * Timestamp of when the customer cart item was added
291
+ */
292
+ time?: string;
293
+ }
294
+ declare namespace CustomerCartDto {
295
+ const StatusEnum: {
296
+ readonly CheckedOut: "checked_out";
297
+ readonly Preparing: "preparing";
298
+ readonly Prepared: "PREPARED";
299
+ readonly Delivered: "delivered";
300
+ readonly Cancelled: "cancelled";
301
+ readonly New: "new";
302
+ };
303
+ type StatusEnum = typeof StatusEnum[keyof typeof StatusEnum];
304
+ }
305
+
306
+ /**
307
+ * API Gateway
308
+ *
309
+ *
310
+ *
311
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
312
+ * https://openapi-generator.tech
313
+ * Do not edit the class manually.
314
+ */
315
+
316
+ interface CustomerDto {
317
+ /**
318
+ * Unique identifier of the customer
319
+ */
320
+ id: string;
321
+ /**
322
+ * Name of the customer
323
+ */
324
+ name: string;
325
+ /**
326
+ * Whether the customer is verified
327
+ */
328
+ verified: boolean;
329
+ /**
330
+ * Whether the customer is the host
331
+ */
332
+ isHost: boolean;
333
+ /**
334
+ * Table information where the customer is seated
335
+ */
336
+ table?: TableResponseDto;
337
+ /**
338
+ * Unique identifier of the table
339
+ */
340
+ tableId: string;
341
+ /**
342
+ * Customer cart items
343
+ */
344
+ carts?: Array<CustomerCartDto>;
345
+ /**
346
+ * Waiter call requests made by this customer
347
+ */
348
+ waiterCalls?: Array<CallWaiterDto>;
349
+ }
350
+
351
+ /**
352
+ * API Gateway
353
+ *
354
+ *
355
+ *
356
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
357
+ * https://openapi-generator.tech
358
+ * Do not edit the class manually.
359
+ */
360
+
361
+ interface TableResponseDto {
362
+ /**
363
+ * Unique table identifier
364
+ */
365
+ id: string;
366
+ /**
367
+ * Host ID (customer who created the table)
368
+ */
369
+ hostId?: string;
370
+ /**
371
+ * Host customer information
372
+ */
373
+ host?: CustomerDto;
374
+ /**
375
+ * Tip amount for the table
376
+ */
377
+ tip: number;
378
+ /**
379
+ * Table number
380
+ */
381
+ number: number;
382
+ /**
383
+ * Seating capacity of the table
384
+ */
385
+ capacity: number;
386
+ /**
387
+ * Current status of the table
388
+ */
389
+ status: TableResponseDto.StatusEnum;
390
+ /**
391
+ * Branch ID where the table belongs
392
+ */
393
+ branchId: string;
394
+ /**
395
+ * Whether the table is waiter-managed
396
+ */
397
+ waiterManaged?: boolean;
398
+ /**
399
+ * Assigned waiter information
400
+ */
401
+ waiter?: WaiterDto;
402
+ /**
403
+ * Carts associated with this table
404
+ */
405
+ carts?: Array<CartDto>;
406
+ customers: Array<Array<CustomerDto>>;
407
+ /**
408
+ * Whether the waiter is being called by the table
409
+ */
410
+ callingWaiter?: boolean;
411
+ }
412
+ declare namespace TableResponseDto {
413
+ const StatusEnum: {
414
+ readonly Free: "free";
415
+ readonly Occupied: "occupied";
416
+ readonly Reserved: "reserved";
417
+ };
418
+ type StatusEnum = typeof StatusEnum[keyof typeof StatusEnum];
419
+ }
420
+
421
+ declare abstract class TableStore extends BaseStore<TableResponseDto> {
422
+ protected socketService: SocketService;
423
+ constructor();
424
+ abstract preload(): Promise<TableResponseDto[]>;
425
+ static ɵfac: i0.ɵɵFactoryDeclaration<TableStore, never>;
426
+ static ɵprov: i0.ɵɵInjectableDeclaration<TableStore>;
427
+ }
428
+
429
+ declare abstract class CartStore extends BaseStore<CartDto> {
430
+ protected socketService: SocketService;
431
+ constructor(socketService: SocketService);
432
+ static ɵfac: i0.ɵɵFactoryDeclaration<CartStore, never>;
433
+ static ɵprov: i0.ɵɵInjectableDeclaration<CartStore>;
434
+ }
435
+
436
+ /**
437
+ * API Gateway
438
+ *
439
+ *
440
+ *
441
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
442
+ * https://openapi-generator.tech
443
+ * Do not edit the class manually.
444
+ */
445
+ interface MenuItemReviewStatsDto {
446
+ /**
447
+ * Average star rating for the menu item, or null if there are no reviews.
448
+ */
449
+ average: number | null;
450
+ /**
451
+ * Total number of reviews for the menu item.
452
+ */
453
+ count: number;
454
+ }
455
+
456
+ /**
457
+ * API Gateway
458
+ *
459
+ *
460
+ *
461
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
462
+ * https://openapi-generator.tech
463
+ * Do not edit the class manually.
464
+ */
465
+ interface MenuItemReviewDto {
466
+ /**
467
+ * Menu Item ID
468
+ */
469
+ menuItemId: string;
470
+ /**
471
+ * Customer ID
472
+ */
473
+ customerId?: string;
474
+ /**
475
+ * Star rating
476
+ */
477
+ starRating: number;
478
+ /**
479
+ * Review message
480
+ */
481
+ message?: string;
482
+ }
483
+
484
+ /**
485
+ * API Gateway
486
+ *
487
+ *
488
+ *
489
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
490
+ * https://openapi-generator.tech
491
+ * Do not edit the class manually.
492
+ */
493
+
494
+ interface MenuItemDto {
495
+ /**
496
+ * Id of the menu item
497
+ */
498
+ id: string;
499
+ /**
500
+ * Name of the menu item
501
+ */
502
+ name: string;
503
+ /**
504
+ * Image URL or base64 string
505
+ */
506
+ image: string;
507
+ /**
508
+ * Price of the menu item
509
+ */
510
+ price: number;
511
+ /**
512
+ * Indicates if the menu item is prepared in the kitchen
513
+ */
514
+ isKitchenPrepared: boolean;
515
+ /**
516
+ * Description of the menu item
517
+ */
518
+ description: string;
519
+ /**
520
+ * UUID of the menu group this item belongs to
521
+ */
522
+ menuGroupId: string;
523
+ /**
524
+ * List of reviews for the menu item
525
+ */
526
+ reviews?: Array<MenuItemReviewDto>;
527
+ /**
528
+ * Review statistics for the menu item
529
+ */
530
+ reviewStats?: MenuItemReviewStatsDto;
531
+ }
532
+
533
+ declare abstract class MenuStore extends BaseStore<MenuItemDto> {
534
+ protected socketService: SocketService;
535
+ constructor(socketService: SocketService);
536
+ getMenu(branchId: string): Promise<void>;
537
+ getMenuItemReviews(menuItemId: string): Promise<void>;
538
+ createMenuItemReview(menuItemId: string, rating: number, comment: string): Promise<void>;
539
+ static ɵfac: i0.ɵɵFactoryDeclaration<MenuStore, never>;
540
+ static ɵprov: i0.ɵɵInjectableDeclaration<MenuStore>;
541
+ }
542
+
543
+ /**
544
+ * API Gateway
545
+ *
546
+ *
547
+ *
548
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
549
+ * https://openapi-generator.tech
550
+ * Do not edit the class manually.
551
+ */
552
+
553
+ interface WaiterCallResponseDto {
554
+ /**
555
+ * Unique identifier of the waiter call
556
+ */
557
+ id: string;
558
+ /**
559
+ * ID of the customer making the call
560
+ */
561
+ customerId: string;
562
+ /**
563
+ * Whether the call has been resolved
564
+ */
565
+ isResolved: boolean;
566
+ /**
567
+ * Message or reason for the call
568
+ */
569
+ message: string;
570
+ /**
571
+ * ID of the table where the call was made
572
+ */
573
+ tableId: string;
574
+ /**
575
+ * Table number for easy identification
576
+ */
577
+ tableNumber: number;
578
+ /**
579
+ * Customer information who made the call
580
+ */
581
+ customer?: CustomerDto;
582
+ }
583
+
584
+ declare abstract class CallWaiterStore extends BaseStore<WaiterCallResponseDto> {
585
+ protected socketService: SocketService;
586
+ constructor(socketService: SocketService);
587
+ abstract preload(): Promise<WaiterCallResponseDto[]>;
588
+ static ɵfac: i0.ɵɵFactoryDeclaration<CallWaiterStore, never>;
589
+ static ɵprov: i0.ɵɵInjectableDeclaration<CallWaiterStore>;
590
+ }
591
+
592
+ /**
593
+ * API Gateway
594
+ *
595
+ *
596
+ *
597
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
598
+ * https://openapi-generator.tech
599
+ * Do not edit the class manually.
600
+ */
601
+ interface CustomerAuthControllerApproveCustomerLoginRequest {
602
+ /**
603
+ * Customer ID to approve
604
+ */
605
+ customerId: string;
606
+ /**
607
+ * Table ID for the customer
608
+ */
609
+ tableId: string;
610
+ }
611
+
612
+ /**
613
+ * API Gateway
614
+ *
615
+ *
616
+ *
617
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
618
+ * https://openapi-generator.tech
619
+ * Do not edit the class manually.
620
+ */
621
+ interface CustomerLoginRequestDto {
622
+ /**
623
+ * Id of the customer.
624
+ */
625
+ id?: string;
626
+ /**
627
+ * Name of the customer.
628
+ */
629
+ name: string;
630
+ /**
631
+ * Unique identifier for the restaurant where the customer is located.
632
+ */
633
+ restaurantId: string;
634
+ /**
635
+ * Unique identifier for the branch of the restaurant.
636
+ */
637
+ branchId: string;
638
+ /**
639
+ * The table number assigned to the customer.
640
+ */
641
+ tableNo: number;
642
+ /**
643
+ * The table id assigned to the customer.
644
+ */
645
+ tableId: string;
646
+ }
647
+
648
+ declare abstract class CustomerLoginStore extends BaseStore<CustomerLoginRequestDto> {
649
+ protected socketService: SocketService;
650
+ constructor(socketService: SocketService);
651
+ getPendingLogins(): void;
652
+ approveCustomerLogin(customerId: string, tableId: string, customerAuthControllerApproveCustomerLogin: (payload: CustomerAuthControllerApproveCustomerLoginRequest) => Observable<CustomerAuthControllerApproveCustomerLoginRequest>): Promise<void>;
653
+ static ɵfac: i0.ɵɵFactoryDeclaration<CustomerLoginStore, never>;
654
+ static ɵprov: i0.ɵɵInjectableDeclaration<CustomerLoginStore>;
655
+ }
656
+
657
+ /**
658
+ * Provides all services needed for the realtime store to function.
659
+ * Use this function in your standalone application's bootstrapApplication providers array.
660
+ *
661
+ * @example
662
+ * ```typescript
663
+ * bootstrapApplication(AppComponent, {
664
+ * providers: [
665
+ * provideRealtimeStore()
666
+ * ]
667
+ * });
668
+ * ```
669
+ */
670
+ declare function provideRealtimeStore(): EnvironmentProviders[];
671
+
672
+ declare function provideRealtimeStoreEnvironment(environment: RealtimeStoreEnvironment): Provider;
673
+
674
+ export { BaseStore, CallWaiterStore, CartStore, CustomerLoginStore, MenuStore, REALTIME_STORE_ENVIRONMENT, RealtimeStoreModule, SocketEvents, SocketService, SocketSuccessEvents, TableStore, defaultRealtimeStoreEnvironment, provideRealtimeStore, provideRealtimeStoreEnvironment };
675
+ export type { RealtimeStoreEnvironment, WaiterCallResponseDto };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serve-socket",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Real-time WebSocket service for restaurant waiter coordination",
5
5
  "license": "MIT",
6
6
  "author": "Serve+ Team",
@@ -23,10 +23,15 @@
23
23
  "dependencies": {
24
24
  "tslib": "^2.3.0"
25
25
  },
26
- "scripts": {
27
- "build": "ng build serve-socket",
28
- "publish": "npm publish",
29
- "prepublishOnly": "npm run build"
30
- },
31
- "sideEffects": false
26
+ "sideEffects": false,
27
+ "module": "fesm2022/serve-socket.mjs",
28
+ "exports": {
29
+ "./package.json": {
30
+ "default": "./package.json"
31
+ },
32
+ ".": {
33
+ "types": "./index.d.ts",
34
+ "default": "./fesm2022/serve-socket.mjs"
35
+ }
36
+ }
32
37
  }