serve-socket 1.0.11 → 1.0.13

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,549 @@
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
+ this.initialize().then(() => { });
330
+ }
331
+ async initialize() {
332
+ await this.delayPreloadUntil();
333
+ this.setupSocketSubscriptions();
334
+ this.refresh();
335
+ this.socketService.reconnect$.subscribe(async () => {
336
+ await this.delayPreloadUntil();
337
+ this.refresh();
338
+ });
339
+ }
340
+ refresh() {
341
+ this.preload().then(x => this.dataSubject.next(x));
342
+ }
343
+ /**
344
+ * Hook subclasses can override to delay initial preload and reconnect refreshes.
345
+ * By default it resolves immediately. Subclasses that need to wait for authentication
346
+ * can override this to await their auth observable (e.g. wait for authenticatedUser$).
347
+ */
348
+ async delayPreloadUntil() {
349
+ return Promise.resolve();
350
+ }
351
+ // Helper methods for stores
352
+ updateItems(items) {
353
+ console.log('setting', items);
354
+ this.dataSubject.next(items);
355
+ }
356
+ addItem(item) {
357
+ console.log('adding', item);
358
+ const currentItems = this.dataSubject.value;
359
+ this.dataSubject.next([...currentItems, item]);
360
+ }
361
+ updateItem(updatedItem, idField) {
362
+ console.log('updating', updatedItem);
363
+ const currentItems = this.dataSubject.value;
364
+ const updatedItems = currentItems.map(item => item[idField] === updatedItem[idField]
365
+ ? { ...item, ...updatedItem }
366
+ : item);
367
+ this.dataSubject.next(updatedItems);
368
+ }
369
+ removeItem(id, idField) {
370
+ console.log('removing', id);
371
+ const currentItems = this.dataSubject.value;
372
+ const filteredItems = currentItems.filter(item => item[idField] !== id);
373
+ this.dataSubject.next(filteredItems);
374
+ }
375
+ setLoading(isLoading) {
376
+ this.loadingSubject.next(isLoading);
377
+ }
378
+ setError(error) {
379
+ this.errorSubject.next(error);
380
+ }
381
+ // Helper to subscribe to socket events with typesafety
382
+ subscribeToEvent(event, handler) {
383
+ this.socketService.on(event).subscribe(handler);
384
+ }
385
+ getAll() {
386
+ return this.dataSubject.value;
387
+ }
388
+ getById(id, idField) {
389
+ return this.dataSubject.value.find(item => item[idField] === id);
390
+ }
391
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: BaseStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
392
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: BaseStore });
393
+ }
394
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: BaseStore, decorators: [{
395
+ type: Injectable
396
+ }], ctorParameters: () => [{ type: SocketService }] });
397
+
398
+ class TableStore extends BaseStore {
399
+ socketService = inject(SocketService);
400
+ constructor() {
401
+ const socketService = inject(SocketService);
402
+ super(socketService);
403
+ }
404
+ setupSocketSubscriptions() {
405
+ this.subscribeToEvent(SocketSuccessEvents.TABLE_CREATED, (table) => this.addItem(table));
406
+ this.subscribeToEvent(SocketSuccessEvents.TABLE_ASSIGNED, (table) => this.updateItem(table, 'id'));
407
+ this.subscribeToEvent(SocketSuccessEvents.TABLE_STATUS_UPDATED, (table) => this.updateItem(table, 'id'));
408
+ this.subscribeToEvent(SocketSuccessEvents.TABLE_RELEASED, (table) => this.updateItem(table, 'id'));
409
+ }
410
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
411
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStore });
412
+ }
413
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: TableStore, decorators: [{
414
+ type: Injectable
415
+ }], ctorParameters: () => [] });
416
+
417
+ class CartStore extends BaseStore {
418
+ socketService;
419
+ constructor(socketService) {
420
+ super(socketService);
421
+ this.socketService = socketService;
422
+ }
423
+ setupSocketSubscriptions() {
424
+ this.subscribeToEvent(SocketSuccessEvents.CUSTOMER_CREATE_OR_UPDATE_CART_SUCCESS, (cart) => this.updateItem(cart, 'id'));
425
+ this.subscribeToEvent(SocketSuccessEvents.CUSTOMER_REMOVE_FROM_CART_SUCCESS, (data) => {
426
+ this.removeItem(data.cartId, 'id');
427
+ });
428
+ }
429
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CartStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
430
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CartStore });
431
+ }
432
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CartStore, decorators: [{
433
+ type: Injectable
434
+ }], ctorParameters: () => [{ type: SocketService }] });
435
+
436
+ class MenuStore extends BaseStore {
437
+ socketService;
438
+ constructor(socketService) {
439
+ super(socketService);
440
+ this.socketService = socketService;
441
+ }
442
+ setupSocketSubscriptions() {
443
+ this.subscribeToEvent(SocketSuccessEvents.CUSTOMER_GET_MENU_SUCCESS, (menuItems) => this.updateItems(menuItems));
444
+ }
445
+ async getMenu(branchId) {
446
+ this.socketService.emit(SocketEvents.CUSTOMER_GET_MENU, { branchId });
447
+ }
448
+ async getMenuItemReviews(menuItemId) {
449
+ this.socketService.emit(SocketEvents.CUSTOMER_GET_MENU_ITEM_REVIEWS, { menuItemId });
450
+ }
451
+ async createMenuItemReview(menuItemId, rating, comment) {
452
+ this.socketService.emit(SocketEvents.CUSTOMER_CREATE_MENU_ITEM_REVIEW, {
453
+ menuItemId,
454
+ rating,
455
+ comment
456
+ });
457
+ }
458
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: MenuStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
459
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: MenuStore });
460
+ }
461
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: MenuStore, decorators: [{
462
+ type: Injectable
463
+ }], ctorParameters: () => [{ type: SocketService }] });
464
+
465
+ class CallWaiterStore extends BaseStore {
466
+ socketService;
467
+ constructor(socketService) {
468
+ super(socketService);
469
+ this.socketService = socketService;
470
+ }
471
+ setupSocketSubscriptions() {
472
+ this.subscribeToEvent(SocketSuccessEvents.WAITER_RECEIVE_CALL, (request) => this.addItem(request));
473
+ }
474
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CallWaiterStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
475
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CallWaiterStore });
476
+ }
477
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CallWaiterStore, decorators: [{
478
+ type: Injectable
479
+ }], ctorParameters: () => [{ type: SocketService }] });
480
+
481
+ class CustomerLoginStore extends BaseStore {
482
+ socketService;
483
+ constructor(socketService) {
484
+ super(socketService);
485
+ this.socketService = socketService;
486
+ }
487
+ setupSocketSubscriptions() {
488
+ this.subscribeToEvent(SocketSuccessEvents.GET_PENDING_CUSTOMER_LOGINS_SUCCESS, (logins) => this.updateItems(logins));
489
+ }
490
+ getPendingLogins() {
491
+ this.socketService.emit(SocketEvents.GET_PENDING_CUSTOMER_LOGINS);
492
+ }
493
+ async approveCustomerLogin(customerId, tableId, customerAuthControllerApproveCustomerLogin) {
494
+ const approveData = {
495
+ customerId,
496
+ tableId
497
+ };
498
+ try {
499
+ await firstValueFrom(customerAuthControllerApproveCustomerLogin(approveData));
500
+ this.removeItem(customerId, 'id');
501
+ }
502
+ catch (error) {
503
+ console.error(`Failed to approve customer login for ${customerId}:`, error);
504
+ this.setError(`Failed to approve customer login`);
505
+ }
506
+ }
507
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CustomerLoginStore, deps: [{ token: SocketService }], target: i0.ɵɵFactoryTarget.Injectable });
508
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CustomerLoginStore });
509
+ }
510
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CustomerLoginStore, decorators: [{
511
+ type: Injectable
512
+ }], ctorParameters: () => [{ type: SocketService }] });
513
+
514
+ /**
515
+ * Provides all services needed for the realtime store to function.
516
+ * Use this function in your standalone application's bootstrapApplication providers array.
517
+ *
518
+ * @example
519
+ * ```typescript
520
+ * bootstrapApplication(AppComponent, {
521
+ * providers: [
522
+ * provideRealtimeStore()
523
+ * ]
524
+ * });
525
+ * ```
526
+ */
527
+ function provideRealtimeStore() {
528
+ return [
529
+ provideHttpClient(withInterceptorsFromDi())
530
+ ];
531
+ }
532
+
533
+ function provideRealtimeStoreEnvironment(environment) {
534
+ return {
535
+ provide: REALTIME_STORE_ENVIRONMENT,
536
+ useValue: environment
537
+ };
538
+ }
539
+
540
+ /*
541
+ * Public API Surface of realtime-store
542
+ */
543
+
544
+ /**
545
+ * Generated bundle index. Do not edit.
546
+ */
547
+
548
+ export { BaseStore, CallWaiterStore, CartStore, CustomerLoginStore, MenuStore, REALTIME_STORE_ENVIRONMENT, RealtimeStoreModule, SocketEvents, SocketService, SocketSuccessEvents, TableStore, defaultRealtimeStoreEnvironment, provideRealtimeStore, provideRealtimeStoreEnvironment };
549
+ //# 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 this.initialize().then(() => { });\n }\n\n private async initialize(): Promise<void> {\n await this.delayPreloadUntil();\n this.setupSocketSubscriptions();\n this.refresh();\n\n this.socketService.reconnect$.subscribe(async () => {\n await this.delayPreloadUntil();\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 protected abstract setupSocketSubscriptions(): void;\n\n /**\n * Hook subclasses can override to delay initial preload and reconnect refreshes.\n * By default it resolves immediately. Subclasses that need to wait for authentication\n * can override this to await their auth observable (e.g. wait for authenticatedUser$).\n */\n protected async delayPreloadUntil(): Promise<void> {\n return Promise.resolve();\n }\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\n protected override setupSocketSubscriptions(): void {\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\n protected override setupSocketSubscriptions(): void {\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\n protected override setupSocketSubscriptions(): void {\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\n protected override setupSocketSubscriptions(): void {\n this.subscribeToEvent<WaiterCallResponseDto>(\n SocketSuccessEvents.WAITER_RECEIVE_CALL,\n (request) => 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 }\n\n protected override setupSocketSubscriptions(): void {\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;;AAIX,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;;;4FAIX,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAR/B,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACN,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACL,YAAY;AACZ,wBAAA,gBAAgB;AACnB,qBAAA;AACD,oBAAA,OAAO,EAAE;AACZ,iBAAA;;;ACVM,MAAM,+BAA+B,GAA6B;;AAErE,IAAA,MAAM,EAAE,CAAA,OAAA,EAAU,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAA,KAAA,CAAO;;;MCHxC,0BAA0B,GAA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BAAiB,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,688 @@
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 initialize;
124
+ private refresh;
125
+ abstract preload(): Promise<T[]>;
126
+ protected abstract setupSocketSubscriptions(): void;
127
+ /**
128
+ * Hook subclasses can override to delay initial preload and reconnect refreshes.
129
+ * By default it resolves immediately. Subclasses that need to wait for authentication
130
+ * can override this to await their auth observable (e.g. wait for authenticatedUser$).
131
+ */
132
+ protected delayPreloadUntil(): Promise<void>;
133
+ protected updateItems(items: T[]): void;
134
+ protected addItem(item: T): void;
135
+ protected updateItem(updatedItem: Partial<T>, idField: keyof T): void;
136
+ protected removeItem(id: any, idField: keyof T): void;
137
+ protected setLoading(isLoading: boolean): void;
138
+ protected setError(error: string | null): void;
139
+ protected subscribeToEvent<R>(event: string, handler: (data: R) => void): void;
140
+ getAll(): T[];
141
+ getById(id: any, idField: keyof T): T | undefined;
142
+ static ɵfac: i0.ɵɵFactoryDeclaration<BaseStore<any>, never>;
143
+ static ɵprov: i0.ɵɵInjectableDeclaration<BaseStore<any>>;
144
+ }
145
+
146
+ /**
147
+ * API Gateway
148
+ *
149
+ *
150
+ *
151
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
152
+ * https://openapi-generator.tech
153
+ * Do not edit the class manually.
154
+ */
155
+ interface WaiterDto {
156
+ /**
157
+ * Unique identifier of the waiter
158
+ */
159
+ id: string;
160
+ /**
161
+ * Name of the waiter
162
+ */
163
+ name: string;
164
+ /**
165
+ * Unique username for the waiter
166
+ */
167
+ username: string;
168
+ /**
169
+ * Encrypted password for the waiter
170
+ */
171
+ password?: string;
172
+ /**
173
+ * Socket key for real-time communication
174
+ */
175
+ socketKey?: string;
176
+ /**
177
+ * Tables assigned to this waiter
178
+ */
179
+ tables?: Array<string>;
180
+ }
181
+
182
+ /**
183
+ * API Gateway
184
+ *
185
+ *
186
+ *
187
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
188
+ * https://openapi-generator.tech
189
+ * Do not edit the class manually.
190
+ */
191
+ interface CallWaiterDtoCustomer {
192
+ id: string;
193
+ name: string;
194
+ verified: boolean;
195
+ isHost: boolean;
196
+ tableId: string;
197
+ }
198
+
199
+ /**
200
+ * API Gateway
201
+ *
202
+ *
203
+ *
204
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
205
+ * https://openapi-generator.tech
206
+ * Do not edit the class manually.
207
+ */
208
+
209
+ interface CallWaiterDto {
210
+ /**
211
+ * Unique identifier of the call waiter request
212
+ */
213
+ id: string;
214
+ /**
215
+ * ID of the customer making the waiter call
216
+ */
217
+ customerId: string;
218
+ /**
219
+ * Whether the waiter call has been resolved
220
+ */
221
+ isResolved: boolean;
222
+ /**
223
+ * Message or reason for calling the waiter
224
+ */
225
+ message?: string;
226
+ customer?: CallWaiterDtoCustomer;
227
+ }
228
+
229
+ /**
230
+ * API Gateway
231
+ *
232
+ *
233
+ *
234
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
235
+ * https://openapi-generator.tech
236
+ * Do not edit the class manually.
237
+ */
238
+
239
+ interface CartDto {
240
+ /**
241
+ * UUID of the cart
242
+ */
243
+ id?: string;
244
+ /**
245
+ * UUID of the table associated with this cart
246
+ */
247
+ tableId: string;
248
+ /**
249
+ * UUID of the menu item for this cart
250
+ */
251
+ menuItemId: string;
252
+ /**
253
+ * Customer cart items within this cart
254
+ */
255
+ customerCarts?: Array<CustomerCartDto>;
256
+ }
257
+
258
+ /**
259
+ * API Gateway
260
+ *
261
+ *
262
+ *
263
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
264
+ * https://openapi-generator.tech
265
+ * Do not edit the class manually.
266
+ */
267
+
268
+ interface CustomerCartDto {
269
+ /**
270
+ * UUID of the customer cart item
271
+ */
272
+ id?: string;
273
+ /**
274
+ * UUID of the customer placing the order
275
+ */
276
+ customerId: string;
277
+ /**
278
+ * Customer details
279
+ */
280
+ customer?: CustomerDto;
281
+ /**
282
+ * UUID of the main cart this item belongs to
283
+ */
284
+ cartItemId: string;
285
+ /**
286
+ * Cart item details
287
+ */
288
+ cartItem?: CartDto;
289
+ /**
290
+ * Quantity of the item ordered by this customer
291
+ */
292
+ quantity: number;
293
+ /**
294
+ * Current status of this customer\'s cart item
295
+ */
296
+ status?: CustomerCartDto.StatusEnum;
297
+ /**
298
+ * Timestamp of when the customer cart item was added
299
+ */
300
+ time?: string;
301
+ }
302
+ declare namespace CustomerCartDto {
303
+ const StatusEnum: {
304
+ readonly CheckedOut: "checked_out";
305
+ readonly Preparing: "preparing";
306
+ readonly Prepared: "PREPARED";
307
+ readonly Delivered: "delivered";
308
+ readonly Cancelled: "cancelled";
309
+ readonly New: "new";
310
+ };
311
+ type StatusEnum = typeof StatusEnum[keyof typeof StatusEnum];
312
+ }
313
+
314
+ /**
315
+ * API Gateway
316
+ *
317
+ *
318
+ *
319
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
320
+ * https://openapi-generator.tech
321
+ * Do not edit the class manually.
322
+ */
323
+
324
+ interface CustomerDto {
325
+ /**
326
+ * Unique identifier of the customer
327
+ */
328
+ id: string;
329
+ /**
330
+ * Name of the customer
331
+ */
332
+ name: string;
333
+ /**
334
+ * Whether the customer is verified
335
+ */
336
+ verified: boolean;
337
+ /**
338
+ * Whether the customer is the host
339
+ */
340
+ isHost: boolean;
341
+ /**
342
+ * Table information where the customer is seated
343
+ */
344
+ table?: TableResponseDto;
345
+ /**
346
+ * Unique identifier of the table
347
+ */
348
+ tableId: string;
349
+ /**
350
+ * Customer cart items
351
+ */
352
+ carts?: Array<CustomerCartDto>;
353
+ /**
354
+ * Waiter call requests made by this customer
355
+ */
356
+ waiterCalls?: Array<CallWaiterDto>;
357
+ }
358
+
359
+ /**
360
+ * API Gateway
361
+ *
362
+ *
363
+ *
364
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
365
+ * https://openapi-generator.tech
366
+ * Do not edit the class manually.
367
+ */
368
+
369
+ interface TableResponseDto {
370
+ /**
371
+ * Unique table identifier
372
+ */
373
+ id: string;
374
+ /**
375
+ * Host ID (customer who created the table)
376
+ */
377
+ hostId?: string;
378
+ /**
379
+ * Host customer information
380
+ */
381
+ host?: CustomerDto;
382
+ /**
383
+ * Tip amount for the table
384
+ */
385
+ tip: number;
386
+ /**
387
+ * Table number
388
+ */
389
+ number: number;
390
+ /**
391
+ * Seating capacity of the table
392
+ */
393
+ capacity: number;
394
+ /**
395
+ * Current status of the table
396
+ */
397
+ status: TableResponseDto.StatusEnum;
398
+ /**
399
+ * Branch ID where the table belongs
400
+ */
401
+ branchId: string;
402
+ /**
403
+ * Whether the table is waiter-managed
404
+ */
405
+ waiterManaged?: boolean;
406
+ /**
407
+ * Assigned waiter information
408
+ */
409
+ waiter?: WaiterDto;
410
+ /**
411
+ * Carts associated with this table
412
+ */
413
+ carts?: Array<CartDto>;
414
+ customers: Array<Array<CustomerDto>>;
415
+ /**
416
+ * Whether the waiter is being called by the table
417
+ */
418
+ callingWaiter?: boolean;
419
+ }
420
+ declare namespace TableResponseDto {
421
+ const StatusEnum: {
422
+ readonly Free: "free";
423
+ readonly Occupied: "occupied";
424
+ readonly Reserved: "reserved";
425
+ };
426
+ type StatusEnum = typeof StatusEnum[keyof typeof StatusEnum];
427
+ }
428
+
429
+ declare abstract class TableStore extends BaseStore<TableResponseDto> {
430
+ protected socketService: SocketService;
431
+ constructor();
432
+ protected setupSocketSubscriptions(): void;
433
+ abstract preload(): Promise<TableResponseDto[]>;
434
+ static ɵfac: i0.ɵɵFactoryDeclaration<TableStore, never>;
435
+ static ɵprov: i0.ɵɵInjectableDeclaration<TableStore>;
436
+ }
437
+
438
+ declare abstract class CartStore extends BaseStore<CartDto> {
439
+ protected socketService: SocketService;
440
+ constructor(socketService: SocketService);
441
+ protected setupSocketSubscriptions(): void;
442
+ static ɵfac: i0.ɵɵFactoryDeclaration<CartStore, never>;
443
+ static ɵprov: i0.ɵɵInjectableDeclaration<CartStore>;
444
+ }
445
+
446
+ /**
447
+ * API Gateway
448
+ *
449
+ *
450
+ *
451
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
452
+ * https://openapi-generator.tech
453
+ * Do not edit the class manually.
454
+ */
455
+ interface MenuItemReviewStatsDto {
456
+ /**
457
+ * Average star rating for the menu item, or null if there are no reviews.
458
+ */
459
+ average: number | null;
460
+ /**
461
+ * Total number of reviews for the menu item.
462
+ */
463
+ count: number;
464
+ }
465
+
466
+ /**
467
+ * API Gateway
468
+ *
469
+ *
470
+ *
471
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
472
+ * https://openapi-generator.tech
473
+ * Do not edit the class manually.
474
+ */
475
+ interface MenuItemReviewDto {
476
+ /**
477
+ * Menu Item ID
478
+ */
479
+ menuItemId: string;
480
+ /**
481
+ * Customer ID
482
+ */
483
+ customerId?: string;
484
+ /**
485
+ * Star rating
486
+ */
487
+ starRating: number;
488
+ /**
489
+ * Review message
490
+ */
491
+ message?: string;
492
+ }
493
+
494
+ /**
495
+ * API Gateway
496
+ *
497
+ *
498
+ *
499
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
500
+ * https://openapi-generator.tech
501
+ * Do not edit the class manually.
502
+ */
503
+
504
+ interface MenuItemDto {
505
+ /**
506
+ * Id of the menu item
507
+ */
508
+ id: string;
509
+ /**
510
+ * Name of the menu item
511
+ */
512
+ name: string;
513
+ /**
514
+ * Image URL or base64 string
515
+ */
516
+ image: string;
517
+ /**
518
+ * Price of the menu item
519
+ */
520
+ price: number;
521
+ /**
522
+ * Indicates if the menu item is prepared in the kitchen
523
+ */
524
+ isKitchenPrepared: boolean;
525
+ /**
526
+ * Description of the menu item
527
+ */
528
+ description: string;
529
+ /**
530
+ * UUID of the menu group this item belongs to
531
+ */
532
+ menuGroupId: string;
533
+ /**
534
+ * List of reviews for the menu item
535
+ */
536
+ reviews?: Array<MenuItemReviewDto>;
537
+ /**
538
+ * Review statistics for the menu item
539
+ */
540
+ reviewStats?: MenuItemReviewStatsDto;
541
+ }
542
+
543
+ declare abstract class MenuStore extends BaseStore<MenuItemDto> {
544
+ protected socketService: SocketService;
545
+ constructor(socketService: SocketService);
546
+ protected setupSocketSubscriptions(): void;
547
+ getMenu(branchId: string): Promise<void>;
548
+ getMenuItemReviews(menuItemId: string): Promise<void>;
549
+ createMenuItemReview(menuItemId: string, rating: number, comment: string): Promise<void>;
550
+ static ɵfac: i0.ɵɵFactoryDeclaration<MenuStore, never>;
551
+ static ɵprov: i0.ɵɵInjectableDeclaration<MenuStore>;
552
+ }
553
+
554
+ /**
555
+ * API Gateway
556
+ *
557
+ *
558
+ *
559
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
560
+ * https://openapi-generator.tech
561
+ * Do not edit the class manually.
562
+ */
563
+
564
+ interface WaiterCallResponseDto {
565
+ /**
566
+ * Unique identifier of the waiter call
567
+ */
568
+ id: string;
569
+ /**
570
+ * ID of the customer making the call
571
+ */
572
+ customerId: string;
573
+ /**
574
+ * Whether the call has been resolved
575
+ */
576
+ isResolved: boolean;
577
+ /**
578
+ * Message or reason for the call
579
+ */
580
+ message: string;
581
+ /**
582
+ * ID of the table where the call was made
583
+ */
584
+ tableId: string;
585
+ /**
586
+ * Table number for easy identification
587
+ */
588
+ tableNumber: number;
589
+ /**
590
+ * Customer information who made the call
591
+ */
592
+ customer?: CustomerDto;
593
+ }
594
+
595
+ declare abstract class CallWaiterStore extends BaseStore<WaiterCallResponseDto> {
596
+ protected socketService: SocketService;
597
+ constructor(socketService: SocketService);
598
+ protected setupSocketSubscriptions(): void;
599
+ abstract preload(): Promise<WaiterCallResponseDto[]>;
600
+ static ɵfac: i0.ɵɵFactoryDeclaration<CallWaiterStore, never>;
601
+ static ɵprov: i0.ɵɵInjectableDeclaration<CallWaiterStore>;
602
+ }
603
+
604
+ /**
605
+ * API Gateway
606
+ *
607
+ *
608
+ *
609
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
610
+ * https://openapi-generator.tech
611
+ * Do not edit the class manually.
612
+ */
613
+ interface CustomerAuthControllerApproveCustomerLoginRequest {
614
+ /**
615
+ * Customer ID to approve
616
+ */
617
+ customerId: string;
618
+ /**
619
+ * Table ID for the customer
620
+ */
621
+ tableId: string;
622
+ }
623
+
624
+ /**
625
+ * API Gateway
626
+ *
627
+ *
628
+ *
629
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
630
+ * https://openapi-generator.tech
631
+ * Do not edit the class manually.
632
+ */
633
+ interface CustomerLoginRequestDto {
634
+ /**
635
+ * Id of the customer.
636
+ */
637
+ id?: string;
638
+ /**
639
+ * Name of the customer.
640
+ */
641
+ name: string;
642
+ /**
643
+ * Unique identifier for the restaurant where the customer is located.
644
+ */
645
+ restaurantId: string;
646
+ /**
647
+ * Unique identifier for the branch of the restaurant.
648
+ */
649
+ branchId: string;
650
+ /**
651
+ * The table number assigned to the customer.
652
+ */
653
+ tableNo: number;
654
+ /**
655
+ * The table id assigned to the customer.
656
+ */
657
+ tableId: string;
658
+ }
659
+
660
+ declare abstract class CustomerLoginStore extends BaseStore<CustomerLoginRequestDto> {
661
+ protected socketService: SocketService;
662
+ constructor(socketService: SocketService);
663
+ protected setupSocketSubscriptions(): void;
664
+ getPendingLogins(): void;
665
+ approveCustomerLogin(customerId: string, tableId: string, customerAuthControllerApproveCustomerLogin: (payload: CustomerAuthControllerApproveCustomerLoginRequest) => Observable<CustomerAuthControllerApproveCustomerLoginRequest>): Promise<void>;
666
+ static ɵfac: i0.ɵɵFactoryDeclaration<CustomerLoginStore, never>;
667
+ static ɵprov: i0.ɵɵInjectableDeclaration<CustomerLoginStore>;
668
+ }
669
+
670
+ /**
671
+ * Provides all services needed for the realtime store to function.
672
+ * Use this function in your standalone application's bootstrapApplication providers array.
673
+ *
674
+ * @example
675
+ * ```typescript
676
+ * bootstrapApplication(AppComponent, {
677
+ * providers: [
678
+ * provideRealtimeStore()
679
+ * ]
680
+ * });
681
+ * ```
682
+ */
683
+ declare function provideRealtimeStore(): EnvironmentProviders[];
684
+
685
+ declare function provideRealtimeStoreEnvironment(environment: RealtimeStoreEnvironment): Provider;
686
+
687
+ export { BaseStore, CallWaiterStore, CartStore, CustomerLoginStore, MenuStore, REALTIME_STORE_ENVIRONMENT, RealtimeStoreModule, SocketEvents, SocketService, SocketSuccessEvents, TableStore, defaultRealtimeStoreEnvironment, provideRealtimeStore, provideRealtimeStoreEnvironment };
688
+ 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.13",
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
  }