@lyxa.ai/core 1.3.158 → 1.3.159
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/libraries/event/EventEnums.d.ts +3 -1
- package/dist/libraries/event/EventEnums.js +2 -0
- package/dist/libraries/event/EventEnums.js.map +1 -1
- package/dist/libraries/event/events/punch-marketing/sync-all-user-punch-marketing-history-event.d.ts +9 -0
- package/dist/libraries/event/events/punch-marketing/sync-all-user-punch-marketing-history-event.js +17 -0
- package/dist/libraries/event/events/punch-marketing/sync-all-user-punch-marketing-history-event.js.map +1 -0
- package/dist/libraries/event/events/punch-marketing/sync-user-shop-punch-marketing-history-event.d.ts +21 -0
- package/dist/libraries/event/events/punch-marketing/sync-user-shop-punch-marketing-history-event.js +23 -0
- package/dist/libraries/event/events/punch-marketing/sync-user-shop-punch-marketing-history-event.js.map +1 -0
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/utilities/events-common-methods.d.ts +4 -0
- package/dist/utilities/events-common-methods.js +12 -0
- package/dist/utilities/events-common-methods.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,5 +13,7 @@ export declare enum PublishEventEnums {
|
|
|
13
13
|
SYNC_SINGLE_SHOP_CACHE_EVENT = "sync_single_shop_cache_event",
|
|
14
14
|
SYNC_SINGLE_SHOP_ORDER_AGAIN_CACHE_EVENT = "sync_single_shop_order_again_cache_event",
|
|
15
15
|
SYNC_SINGLE_SHOP_SECTIONS_CACHE_EVENT = "sync_single_shop_sections_cache_event",
|
|
16
|
-
SYNC_ALL_CUSTOMIZED_SHOP_SECTIONS_CACHE_EVENT = "sync_all_customized_shop_sections_cache_event"
|
|
16
|
+
SYNC_ALL_CUSTOMIZED_SHOP_SECTIONS_CACHE_EVENT = "sync_all_customized_shop_sections_cache_event",
|
|
17
|
+
SYNC_ALL_USERS_PUNCH_MARKETING_HISTORY_CACHE_EVENT = "sync_all_users_punch_marketing_history_cache_event",
|
|
18
|
+
SYNC_USER_SHOP_PUNCH_MARKETING_HISTORY_CACHE_EVENT = "sync_user_shop_punch_marketing_history_cache_event"
|
|
17
19
|
}
|
|
@@ -18,5 +18,7 @@ var PublishEventEnums;
|
|
|
18
18
|
PublishEventEnums["SYNC_SINGLE_SHOP_ORDER_AGAIN_CACHE_EVENT"] = "sync_single_shop_order_again_cache_event";
|
|
19
19
|
PublishEventEnums["SYNC_SINGLE_SHOP_SECTIONS_CACHE_EVENT"] = "sync_single_shop_sections_cache_event";
|
|
20
20
|
PublishEventEnums["SYNC_ALL_CUSTOMIZED_SHOP_SECTIONS_CACHE_EVENT"] = "sync_all_customized_shop_sections_cache_event";
|
|
21
|
+
PublishEventEnums["SYNC_ALL_USERS_PUNCH_MARKETING_HISTORY_CACHE_EVENT"] = "sync_all_users_punch_marketing_history_cache_event";
|
|
22
|
+
PublishEventEnums["SYNC_USER_SHOP_PUNCH_MARKETING_HISTORY_CACHE_EVENT"] = "sync_user_shop_punch_marketing_history_cache_event";
|
|
21
23
|
})(PublishEventEnums || (exports.PublishEventEnums = PublishEventEnums = {}));
|
|
22
24
|
//# sourceMappingURL=EventEnums.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventEnums.js","sourceRoot":"/","sources":["libraries/event/EventEnums.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"EventEnums.js","sourceRoot":"/","sources":["libraries/event/EventEnums.ts"],"names":[],"mappings":";;;AAAA,IAAY,iBAkBX;AAlBD,WAAY,iBAAiB;IAC5B,4EAAuD,CAAA;IACvD,sEAAiD,CAAA;IACjD,4EAAuD,CAAA;IACvD,sEAAiD,CAAA;IACjD,wGAAmF,CAAA;IACnF,sHAAiG,CAAA;IACjG,oGAA+E,CAAA;IAC/E,sFAAiE,CAAA;IACjE,8FAAyE,CAAA;IACzE,sHAAiG,CAAA;IACjG,4GAAuF,CAAA;IACvF,kFAA6D,CAAA;IAC7D,0GAAqF,CAAA;IACrF,oGAA+E,CAAA;IAC/E,oHAA+F,CAAA;IAC/F,8HAAyG,CAAA;IACzG,8HAAyG,CAAA;AAC1G,CAAC,EAlBW,iBAAiB,iCAAjB,iBAAiB,QAkB5B","sourcesContent":["export enum PublishEventEnums {\n\tADMIN_ACTIVITY_LOGS_EVENT = 'admin_activity_logs_event',\n\tMESSAGE_RECEIVED_EVENT = 'message_received_event',\n\tTICKET_NOTIFICATION_EVENT = 'ticket_notification_event',\n\tCART_ITEM_UPSERT_EVENT = 'cart_item_upsert_event',\n\tSHOP_ACTIVE_TIMINGS_BATCH_PROCESS_EVENT = 'shop_active_timings_batch_process_event',\n\tMONGO_STREAM_CHANGES_BATCH_PROCESS_SHOPS_EVENT = 'mongo_stream_changes_batch_process_shops_event',\n\tBULK_UPDATE_SHOPS_SEARCH_FIELDS_EVENT = 'bulk_update_shops_search_fields_event',\n\tSOCKET_PUSH_NOTIFICATION_EVENT = 'socket_push_notification_event',\n\tBULK_UPDATE_SHOP_ZONE_STATUS_EVENT = 'bulk_update_shop_zone_status_event',\n\tSYNC_ALL_PRODUCTS_PRODUCT_MARKETING_INFO_EVENT = 'sync_all_products_product_marketing_info_event',\n\tSYNC_ALL_SHOPS_AVG_PREPARATION_TIME_EVENT = 'sync_all_shops_avg_preperation_time_event',\n\tSYNC_SINGLE_SHOP_CACHE_EVENT = 'sync_single_shop_cache_event',\n\tSYNC_SINGLE_SHOP_ORDER_AGAIN_CACHE_EVENT = 'sync_single_shop_order_again_cache_event',\n\tSYNC_SINGLE_SHOP_SECTIONS_CACHE_EVENT = 'sync_single_shop_sections_cache_event',\n\tSYNC_ALL_CUSTOMIZED_SHOP_SECTIONS_CACHE_EVENT = 'sync_all_customized_shop_sections_cache_event',\n\tSYNC_ALL_USERS_PUNCH_MARKETING_HISTORY_CACHE_EVENT = 'sync_all_users_punch_marketing_history_cache_event',\n\tSYNC_USER_SHOP_PUNCH_MARKETING_HISTORY_CACHE_EVENT = 'sync_user_shop_punch_marketing_history_cache_event'\n}\n \n"]}
|
package/dist/libraries/event/events/punch-marketing/sync-all-user-punch-marketing-history-event.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { BaseEvent } from '../../BaseEvent';
|
|
3
|
+
import { DTO } from '../../../../utilities/validation/global-validation';
|
|
4
|
+
declare const SyncAllUserShopPunchMarketingHistoryInCacheValidationSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
5
|
+
export type SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheDTO = DTO<typeof SyncAllUserShopPunchMarketingHistoryInCacheValidationSchema>;
|
|
6
|
+
export declare class SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheEvent extends BaseEvent<Record<string, unknown>> {
|
|
7
|
+
constructor(payload: SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheDTO);
|
|
8
|
+
}
|
|
9
|
+
export {};
|
package/dist/libraries/event/events/punch-marketing/sync-all-user-punch-marketing-history-event.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheEvent = void 0;
|
|
7
|
+
const zod_1 = __importDefault(require("zod"));
|
|
8
|
+
const BaseEvent_1 = require("../../BaseEvent");
|
|
9
|
+
const EventEnums_1 = require("../../EventEnums");
|
|
10
|
+
const SyncAllUserShopPunchMarketingHistoryInCacheValidationSchema = zod_1.default.object({});
|
|
11
|
+
class SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheEvent extends BaseEvent_1.BaseEvent {
|
|
12
|
+
constructor(payload) {
|
|
13
|
+
super(EventEnums_1.PublishEventEnums.SYNC_ALL_USERS_PUNCH_MARKETING_HISTORY_CACHE_EVENT, payload);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheEvent = SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheEvent;
|
|
17
|
+
//# sourceMappingURL=sync-all-user-punch-marketing-history-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-all-user-punch-marketing-history-event.js","sourceRoot":"/","sources":["libraries/event/events/punch-marketing/sync-all-user-punch-marketing-history-event.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAoB;AACpB,+CAA4C;AAC5C,iDAAqD;AAGrD,MAAM,2DAA2D,GAAG,aAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAMjF,MAAa,4DAA6D,SAAQ,qBAEjF;IACA,YAAY,OAAmE;QAC9E,KAAK,CACJ,8BAAiB,CAAC,kDAAkD,EACpE,OAAkC,CAClC,CAAC;IACH,CAAC;CACD;AATD,oIASC","sourcesContent":["import z from 'zod';\nimport { BaseEvent } from '../../BaseEvent';\nimport { PublishEventEnums } from '../../EventEnums';\nimport { DTO } from '../../../../utilities/validation/global-validation';\n\nconst SyncAllUserShopPunchMarketingHistoryInCacheValidationSchema = z.object({});\n\nexport type SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheDTO = DTO<\n\ttypeof SyncAllUserShopPunchMarketingHistoryInCacheValidationSchema\n>;\n\nexport class SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheEvent extends BaseEvent<\n\tRecord<string, unknown>\n> {\n\tconstructor(payload: SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheDTO) {\n\t\tsuper(\n\t\t\tPublishEventEnums.SYNC_ALL_USERS_PUNCH_MARKETING_HISTORY_CACHE_EVENT,\n\t\t\tpayload as Record<string, unknown>\n\t\t);\n\t}\n}"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseEvent } from '../../BaseEvent';
|
|
2
|
+
import { ChangeStreamOperationTypes } from '../mongo-stream-changes-batch-process-shops-event';
|
|
3
|
+
import { DTO } from '../../../../utilities/validation/global-validation';
|
|
4
|
+
declare const SyncUserShopPunchMarketingHistoryInCacheValidationSchema: import("zod").ZodObject<{
|
|
5
|
+
userId: import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("mongoose").Types.ObjectId, string>, import("zod").ZodType<import("mongoose").Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
6
|
+
shopId: import("zod").ZodUnion<[import("zod").ZodEffects<import("zod").ZodEffects<import("zod").ZodString, string, string>, import("mongoose").Types.ObjectId, string>, import("zod").ZodType<import("mongoose").Types.ObjectId, import("zod").ZodTypeDef, import("mongoose").Types.ObjectId>]>;
|
|
7
|
+
operation: import("zod").ZodNativeEnum<typeof ChangeStreamOperationTypes>;
|
|
8
|
+
}, "strict", import("zod").ZodTypeAny, {
|
|
9
|
+
userId: import("mongoose").Types.ObjectId;
|
|
10
|
+
shopId: import("mongoose").Types.ObjectId;
|
|
11
|
+
operation: ChangeStreamOperationTypes;
|
|
12
|
+
}, {
|
|
13
|
+
userId: string | import("mongoose").Types.ObjectId;
|
|
14
|
+
shopId: string | import("mongoose").Types.ObjectId;
|
|
15
|
+
operation: ChangeStreamOperationTypes;
|
|
16
|
+
}>;
|
|
17
|
+
export type SyncUserShopPunchMarketingHistoryInCacheValidationDTO = DTO<typeof SyncUserShopPunchMarketingHistoryInCacheValidationSchema>;
|
|
18
|
+
export declare class SyncUserShopPunchMarketingHistoryInCacheEvent extends BaseEvent<Record<string, unknown>> {
|
|
19
|
+
constructor(payload: SyncUserShopPunchMarketingHistoryInCacheValidationDTO);
|
|
20
|
+
}
|
|
21
|
+
export {};
|
package/dist/libraries/event/events/punch-marketing/sync-user-shop-punch-marketing-history-event.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncUserShopPunchMarketingHistoryInCacheEvent = void 0;
|
|
4
|
+
const BaseEvent_1 = require("../../BaseEvent");
|
|
5
|
+
const EventEnums_1 = require("../../EventEnums");
|
|
6
|
+
const mongo_stream_changes_batch_process_shops_event_1 = require("../mongo-stream-changes-batch-process-shops-event");
|
|
7
|
+
const global_validation_1 = require("../../../../utilities/validation/global-validation");
|
|
8
|
+
const baseFields = {
|
|
9
|
+
userId: global_validation_1.ZodValidation.objectId(),
|
|
10
|
+
shopId: global_validation_1.ZodValidation.objectId(),
|
|
11
|
+
operation: global_validation_1.ZodValidation.enumType(mongo_stream_changes_batch_process_shops_event_1.ChangeStreamOperationTypes)
|
|
12
|
+
};
|
|
13
|
+
const schemaBuilder = (0, global_validation_1.createSchemaBuilder)(baseFields);
|
|
14
|
+
const { BaseSchema: SyncUserShopPunchMarketingHistoryInCacheValidationSchema } = schemaBuilder.getAllSchemas({
|
|
15
|
+
createdAt: true,
|
|
16
|
+
});
|
|
17
|
+
class SyncUserShopPunchMarketingHistoryInCacheEvent extends BaseEvent_1.BaseEvent {
|
|
18
|
+
constructor(payload) {
|
|
19
|
+
super(EventEnums_1.PublishEventEnums.SYNC_USER_SHOP_PUNCH_MARKETING_HISTORY_CACHE_EVENT, payload);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.SyncUserShopPunchMarketingHistoryInCacheEvent = SyncUserShopPunchMarketingHistoryInCacheEvent;
|
|
23
|
+
//# sourceMappingURL=sync-user-shop-punch-marketing-history-event.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-user-shop-punch-marketing-history-event.js","sourceRoot":"/","sources":["libraries/event/events/punch-marketing/sync-user-shop-punch-marketing-history-event.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,iDAAqD;AACrD,sHAA+F;AAC/F,0FAA6G;AAE7G,MAAM,UAAU,GAAG;IAClB,MAAM,EAAE,iCAAa,CAAC,QAAQ,EAAE;IAChC,MAAM,EAAE,iCAAa,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,iCAAa,CAAC,QAAQ,CAAC,2EAA0B,CAAC;CAC7D,CAAC;AACF,MAAM,aAAa,GAAG,IAAA,uCAAmB,EAAC,UAAU,CAAC,CAAC;AACtD,MAAM,EAAE,UAAU,EAAE,wDAAwD,EAAE,GAAG,aAAa,CAAC,aAAa,CAAC;IAC5G,SAAS,EAAE,IAAI;CACf,CAAC,CAAC;AAIH,MAAa,6CAA8C,SAAQ,qBAAkC;IACpG,YAAY,OAA8D;QACzE,KAAK,CAAC,8BAAiB,CAAC,kDAAkD,EAAE,OAAkC,CAAC,CAAC;IACjH,CAAC;CACD;AAJD,sGAIC","sourcesContent":["import { BaseEvent } from '../../BaseEvent';\nimport { PublishEventEnums } from '../../EventEnums';\nimport { ChangeStreamOperationTypes } from '../mongo-stream-changes-batch-process-shops-event';\nimport { createSchemaBuilder, DTO, ZodValidation } from '../../../../utilities/validation/global-validation';\n\nconst baseFields = {\n\tuserId: ZodValidation.objectId(),\n\tshopId: ZodValidation.objectId(),\n\toperation: ZodValidation.enumType(ChangeStreamOperationTypes)\n};\nconst schemaBuilder = createSchemaBuilder(baseFields);\nconst { BaseSchema: SyncUserShopPunchMarketingHistoryInCacheValidationSchema } = schemaBuilder.getAllSchemas({\n\tcreatedAt: true,\n});\n\nexport type SyncUserShopPunchMarketingHistoryInCacheValidationDTO = DTO<typeof SyncUserShopPunchMarketingHistoryInCacheValidationSchema>;\n\nexport class SyncUserShopPunchMarketingHistoryInCacheEvent extends BaseEvent<Record<string, unknown>> {\n\tconstructor(payload: SyncUserShopPunchMarketingHistoryInCacheValidationDTO) {\n\t\tsuper(PublishEventEnums.SYNC_USER_SHOP_PUNCH_MARKETING_HISTORY_CACHE_EVENT, payload as Record<string, unknown>);\n\t}\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -8,6 +8,8 @@ import { SyncSingleShopCacheDTO } from '../libraries/event/events/sync-single-sh
|
|
|
8
8
|
import { SyncSingleShopOrderAgainCacheDTO } from '../libraries/event/events/sync-order-again-sections-for-shop-event';
|
|
9
9
|
import { SyncSingleShopSectionsInCacheDTO } from '../libraries/event/events/sync-single-shop-sections-in-cache-event';
|
|
10
10
|
import { SynchronizeAllCustomizedShopSectionsCacheDTO } from '../libraries/event/events/sync-all-customized-shop-sections-cache-event';
|
|
11
|
+
import { SyncUserShopPunchMarketingHistoryInCacheValidationDTO } from '../libraries/event/events/punch-marketing/sync-user-shop-punch-marketing-history-event';
|
|
12
|
+
import { SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheDTO } from '../libraries/event/events/punch-marketing/sync-all-user-punch-marketing-history-event';
|
|
11
13
|
export declare function getChangedFields<T extends Record<string, any>>(oldDoc: T, newDoc: T, payload?: Partial<T>): Record<keyof T, {
|
|
12
14
|
old: any;
|
|
13
15
|
new: any;
|
|
@@ -39,3 +41,5 @@ export declare function publishSyncSingleShopInCacheProcessEvent(payload: SyncSi
|
|
|
39
41
|
export declare function publishSyncSingleShopOrderAgainSectionsInCacheProcessEvent(payload: SyncSingleShopOrderAgainCacheDTO): Promise<void>;
|
|
40
42
|
export declare function publishSyncSingleShopSectionsInCacheProcessEvent(payload: SyncSingleShopSectionsInCacheDTO): Promise<void>;
|
|
41
43
|
export declare function publishAllCustomizedShopSectionsCacheProcessEvent(payload: SynchronizeAllCustomizedShopSectionsCacheDTO): Promise<void>;
|
|
44
|
+
export declare function publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent(payload: SyncUserShopPunchMarketingHistoryInCacheValidationDTO): Promise<void>;
|
|
45
|
+
export declare function publishSyncAllUserPunchMarketingHistoryWithPunchSectionCacheProcessEvent(payload: SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheDTO): Promise<void>;
|
|
@@ -14,6 +14,8 @@ exports.publishSyncSingleShopInCacheProcessEvent = publishSyncSingleShopInCacheP
|
|
|
14
14
|
exports.publishSyncSingleShopOrderAgainSectionsInCacheProcessEvent = publishSyncSingleShopOrderAgainSectionsInCacheProcessEvent;
|
|
15
15
|
exports.publishSyncSingleShopSectionsInCacheProcessEvent = publishSyncSingleShopSectionsInCacheProcessEvent;
|
|
16
16
|
exports.publishAllCustomizedShopSectionsCacheProcessEvent = publishAllCustomizedShopSectionsCacheProcessEvent;
|
|
17
|
+
exports.publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent = publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent;
|
|
18
|
+
exports.publishSyncAllUserPunchMarketingHistoryWithPunchSectionCacheProcessEvent = publishSyncAllUserPunchMarketingHistoryWithPunchSectionCacheProcessEvent;
|
|
17
19
|
const event_1 = require("../libraries/event");
|
|
18
20
|
const mongo_stream_changes_batch_process_shops_event_1 = require("../libraries/event/events/mongo-stream-changes-batch-process-shops-event");
|
|
19
21
|
const admin_logs_event_1 = require("../libraries/event/events/admin-logs-event");
|
|
@@ -26,6 +28,8 @@ const sync_single_shop_in_cache_event_1 = require("../libraries/event/events/syn
|
|
|
26
28
|
const sync_order_again_sections_for_shop_event_1 = require("../libraries/event/events/sync-order-again-sections-for-shop-event");
|
|
27
29
|
const sync_single_shop_sections_in_cache_event_1 = require("../libraries/event/events/sync-single-shop-sections-in-cache-event");
|
|
28
30
|
const sync_all_customized_shop_sections_cache_event_1 = require("../libraries/event/events/sync-all-customized-shop-sections-cache-event");
|
|
31
|
+
const sync_user_shop_punch_marketing_history_event_1 = require("../libraries/event/events/punch-marketing/sync-user-shop-punch-marketing-history-event");
|
|
32
|
+
const sync_all_user_punch_marketing_history_event_1 = require("../libraries/event/events/punch-marketing/sync-all-user-punch-marketing-history-event");
|
|
29
33
|
function getChangedFields(oldDoc, newDoc, payload) {
|
|
30
34
|
const changes = {};
|
|
31
35
|
const oldObj = typeof oldDoc.toObject === 'function' ? oldDoc.toObject() : oldDoc;
|
|
@@ -126,4 +130,12 @@ async function publishAllCustomizedShopSectionsCacheProcessEvent(payload) {
|
|
|
126
130
|
const SyncAllCustomizedShopSectionsCacheProcessEvent = new sync_all_customized_shop_sections_cache_event_1.SynchronizeAllCustomizedShopSectionsCacheEvent({});
|
|
127
131
|
await (0, event_1.publishEvent)(SyncAllCustomizedShopSectionsCacheProcessEvent);
|
|
128
132
|
}
|
|
133
|
+
async function publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent(payload) {
|
|
134
|
+
const syncUserShopPunchMarketingHistoryInCacheEvent = new sync_user_shop_punch_marketing_history_event_1.SyncUserShopPunchMarketingHistoryInCacheEvent(payload);
|
|
135
|
+
await (0, event_1.publishEvent)(syncUserShopPunchMarketingHistoryInCacheEvent);
|
|
136
|
+
}
|
|
137
|
+
async function publishSyncAllUserPunchMarketingHistoryWithPunchSectionCacheProcessEvent(payload) {
|
|
138
|
+
const syncAllUserPunchMarketingHistoryWithPunchSectionsInCacheEvent = new sync_all_user_punch_marketing_history_event_1.SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheEvent(payload);
|
|
139
|
+
await (0, event_1.publishEvent)(syncAllUserPunchMarketingHistoryWithPunchSectionsInCacheEvent);
|
|
140
|
+
}
|
|
129
141
|
//# sourceMappingURL=events-common-methods.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events-common-methods.js","sourceRoot":"/","sources":["utilities/events-common-methods.ts"],"names":[],"mappings":";;AAwCA,4CAyBC;AAwCD,sDAaC;AAKD,wDAKC;AAED,sDAcC;AAED,gFAIC;AAED,gHAMC;AAED,wGAIC;AAED,oGAIC;AAED,gHAMC;AAED,8GAMC;AAED,4FAKC;AAED,gIAMC;AAED,4GAMC;AAED,8GAMC;AAxND,8CAAkD;AAGlD,6IAGkF;AAClF,iFAAoF;AACpF,+HAAuH;AACvH,uJAA6I;AAC7I,6HAG0E;AAC1E,6IAGkF;AAClF,2HAGyE;AACzE,+GAGmE;AACnE,iIAG4E;AAC5E,iIAG4E;AAC5E,2IAAuL;AAKv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AAU,kDAAkD,CACvE,OAAsD;IAEtD,MAAM,+CAA+C,GACpD,IAAI,gGAA+C,CAAC,EAAE,CAAC,CAAC;IACzD,MAAM,IAAA,oBAAY,EAAC,+CAA+C,CAAC,CAAC;AACrE,CAAC;AAEM,KAAK,UAAU,iDAAiD,CACtE,OAAiD;IAEjD,MAAM,8CAA8C,GACnD,IAAI,kFAA0C,CAAC,EAAE,CAAC,CAAC;IACpD,MAAM,IAAA,oBAAY,EAAC,8CAA8C,CAAC,CAAC;AACpE,CAAC;AAEM,KAAK,UAAU,wCAAwC,CAAC,OAA+B;IAC7F,MAAM,4BAA4B,GAAuC,IAAI,4DAA0B,CACtG,OAAO,CACP,CAAC;IACF,MAAM,IAAA,oBAAY,EAAC,4BAA4B,CAAC,CAAC;AAClD,CAAC;AAEM,KAAK,UAAU,0DAA0D,CAC/E,OAAyC;IAEzC,MAAM,wCAAwC,GAC7C,IAAI,+EAAoC,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,IAAA,oBAAY,EAAC,wCAAwC,CAAC,CAAC;AAC9D,CAAC;AAEM,KAAK,UAAU,gDAAgD,CACrE,OAAyC;IAEzC,MAAM,sCAAsC,GAC3C,IAAI,6EAAkC,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,IAAA,oBAAY,EAAC,sCAAsC,CAAC,CAAC;AAC5D,CAAC;AAEM,KAAK,UAAU,iDAAiD,CACtE,OAAqD;IAErD,MAAM,8CAA8C,GACnD,IAAI,8FAA8C,CAAC,EAAE,CAAC,CAAC;IACxD,MAAM,IAAA,oBAAY,EAAC,8CAA8C,CAAC,CAAC;AACpE,CAAC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { publishEvent } from '../libraries/event';\nimport { AdminLogsUpdatedFieldsType } from './enum';\nimport { BaseEvent } from '../libraries/event/BaseEvent';\nimport {\n\tMongoStreamsBatchProcessShopsDTO,\n\tMongoStreamsBatchProcessShopsEvent,\n} from '../libraries/event/events/mongo-stream-changes-batch-process-shops-event';\nimport { AdminActivityLogsEvent } from '../libraries/event/events/admin-logs-event';\nimport { ShopActiveTimingsBatchProcessEvent } from '../libraries/event/events/shop-active-timings-batch-process-event';\nimport { BulkUpdateShopsSearchFieldsBatchProcessEvent } from '../libraries/event/events/bulk-update-shops-search-fields-batch-process-event';\nimport {\n\tBulkUpdateShopsZoneStatusDTO,\n\tBulkUpdateShopsZoneStatusEvent,\n} from '../libraries/event/events/bulk-update-zone-status-in-shops-event';\nimport {\n\tSynchronizeAllProductsProductMarketingInfoDTO,\n\tSynchronizeAllProductsProductMarketingInfoEvent,\n} from '../libraries/event/events/sync-all-products-product-marketing-info-event';\nimport {\n\tSynchronizeAllShopsAvgPreparationTimeDTO,\n\tSynchronizeAllShopsAvgPreparationTimeEvent,\n} from '../libraries/event/events/sync-avg-prep-time-in-all-shops-event';\nimport {\n\tSyncSingleShopCacheDTO,\n\tSyncSingleShopInCacheEvent,\n} from '../libraries/event/events/sync-single-shop-in-cache-event';\nimport {\n\tSyncSingleShopOrderAgainCacheDTO,\n\tSyncSingleShopOrderAgainInCacheEvent,\n} from '../libraries/event/events/sync-order-again-sections-for-shop-event';\nimport {\n\tSyncSingleShopSectionsInCacheDTO,\n\tSyncSingleShopSectionsInCacheEvent,\n} from '../libraries/event/events/sync-single-shop-sections-in-cache-event';\nimport { SynchronizeAllCustomizedShopSectionsCacheDTO, SynchronizeAllCustomizedShopSectionsCacheEvent } from '../libraries/event/events/sync-all-customized-shop-sections-cache-event';\n\n/**\n * Returns changed fields between two objects (shallow comparison).\n */\nexport function getChangedFields<T extends Record<string, any>>(\n\toldDoc: T,\n\tnewDoc: T,\n\tpayload?: Partial<T>\n): Record<keyof T, { old: any; new: any }> {\n\tconst changes = {} as Record<keyof T, { old: any; new: any }>;\n\n\tconst oldObj = typeof oldDoc.toObject === 'function' ? oldDoc.toObject() : oldDoc;\n\tconst newObj = typeof newDoc.toObject === 'function' ? newDoc.toObject() : newDoc;\n\n\tconst keysToCheck = payload\n\t\t? Object.keys(payload)\n\t\t: Array.from(new Set([...Object.keys(oldObj), ...Object.keys(newObj)]));\n\n\tfor (const key of keysToCheck) {\n\t\tconst oldValue = oldObj[key];\n\t\tconst newValue = newObj[key];\n\t\tconst cleanedOld = deepCleanSettingsValues(oldValue);\n\t\tconst cleanedNew = deepCleanSettingsValues(newValue);\n\t\tif (payload || JSON.stringify(cleanedOld) !== JSON.stringify(cleanedNew)) {\n\t\t\tchanges[key as keyof T] = { old: oldValue, new: newValue };\n\t\t}\n\t}\n\n\treturn changes;\n}\n\n// removes _id and deletedAt fields from objects, array of objects and prepares for data that has setting changes\nfunction deepCleanSettingsValues(value: any): any {\n\t// CASE 1: Array\n\tif (Array.isArray(value)) {\n\t\t// If array contains primitives → return as-is\n\t\tif (value.every(v => v === null || typeof v !== 'object')) {\n\t\t\treturn value;\n\t\t}\n\n\t\t// If array contains objects → deep clean each object\n\t\treturn value.map(item => deepCleanSettingsValues(item));\n\t}\n\n\t// CASE 2: Null → return as is\n\tif (value === null) return value;\n\n\t// CASE 3: Plain Object\n\tif (typeof value === 'object') {\n\t\tconst cleanedObj: any = {};\n\n\t\tfor (const key in value) {\n\t\t\tif (key === '_id' || key === 'deletedAt' || value[key] === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tcleanedObj[key] = deepCleanSettingsValues(value[key]);\n\t\t}\n\n\t\treturn cleanedObj;\n\t}\n\n\t// CASE 4: Primitive (string, number, boolean)\n\treturn value;\n}\n\n/**\n * Filters changed fields to only those that exist in the payload.\n */\nexport function filterRelevantChanges<T>(\n\tallChanges: Record<string, { old: any; new: any }>,\n\tpayload: Partial<T>\n): Record<string, { old: any; new: any }> {\n\treturn Object.keys(payload).reduce(\n\t\t(acc, key) => {\n\t\t\tif (allChanges[key]) {\n\t\t\t\tacc[key] = allChanges[key];\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<string, { old: any; new: any }>\n\t);\n}\n\n/**\n * Extracts either 'old' or 'new' values from the changes object.\n */\nexport function extractChangedDocument(\n\tchanges: Record<string, { old: any; new: any }>,\n\ttype: 'old' | 'new'\n): Record<string, any> {\n\treturn Object.fromEntries(Object.entries(changes).map(([key, value]) => [key, value[type]]));\n}\n\nexport async function publishAdminLogsEvent(payload: {\n\tadmin: mongoose.Types.ObjectId;\n\tupdatedField: AdminLogsUpdatedFieldsType;\n\toldDoc: any;\n\tnewDoc: any;\n}) {\n\tconst { admin, updatedField, oldDoc, newDoc } = payload;\n\tconst adminActivityLogsEvent: BaseEvent<Record<string, unknown>> = new AdminActivityLogsEvent({\n\t\tadmin: admin,\n\t\tupdatedField: updatedField,\n\t\toldDocument: oldDoc,\n\t\tnewDocument: newDoc,\n\t});\n\tawait publishEvent(adminActivityLogsEvent);\n}\n\nexport async function publishShopActiveBatchProcessEvent() {\n\tconst shopActiveTimingsBatchProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew ShopActiveTimingsBatchProcessEvent({});\n\tawait publishEvent(shopActiveTimingsBatchProcessEvent);\n}\n\nexport async function publishMongodbStreamsChangesBatchProcessShopsEvent(\n\tpayload: MongoStreamsBatchProcessShopsDTO\n) {\n\tconst mongodbStreamsBatchProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew MongoStreamsBatchProcessShopsEvent(payload);\n\tawait publishEvent(mongodbStreamsBatchProcessEvent);\n}\n\nexport async function publishUpdateShopsSearchFieldsBulkProcessEvent(payload: any) {\n\tconst bulkUpdateShopsSearchFieldsBatchProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew BulkUpdateShopsSearchFieldsBatchProcessEvent(payload);\n\tawait publishEvent(bulkUpdateShopsSearchFieldsBatchProcessEvent);\n}\n\nexport async function publishBulkUpdateShopsZoneStatusProcessEvent(payload: BulkUpdateShopsZoneStatusDTO) {\n\tconst shopsZoneStatusBatchProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew BulkUpdateShopsZoneStatusEvent(payload);\n\tawait publishEvent(shopsZoneStatusBatchProcessEvent);\n}\n\nexport async function publishAllProductsProductMarketingInfoProcessEvent(\n\tpayload: SynchronizeAllProductsProductMarketingInfoDTO\n) {\n\tconst SyncAllProductsProductMarketingInfoProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SynchronizeAllProductsProductMarketingInfoEvent({});\n\tawait publishEvent(SyncAllProductsProductMarketingInfoProcessEvent);\n}\n\nexport async function publishAllShopsAvgPreperationTimeSyncProcessEvent(\n\tpayload: SynchronizeAllShopsAvgPreparationTimeDTO\n) {\n\tconst SyncAllShopsAvgPreperationTimeSyncProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SynchronizeAllShopsAvgPreparationTimeEvent({});\n\tawait publishEvent(SyncAllShopsAvgPreperationTimeSyncProcessEvent);\n}\n\nexport async function publishSyncSingleShopInCacheProcessEvent(payload: SyncSingleShopCacheDTO) {\n\tconst syncSingleShopCacheSyncEvent: BaseEvent<Record<string, unknown>> = new SyncSingleShopInCacheEvent(\n\t\tpayload\n\t);\n\tawait publishEvent(syncSingleShopCacheSyncEvent);\n}\n\nexport async function publishSyncSingleShopOrderAgainSectionsInCacheProcessEvent(\n\tpayload: SyncSingleShopOrderAgainCacheDTO\n) {\n\tconst syncSingleShopOrderAgainInCacheSyncEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SyncSingleShopOrderAgainInCacheEvent(payload);\n\tawait publishEvent(syncSingleShopOrderAgainInCacheSyncEvent);\n}\n\nexport async function publishSyncSingleShopSectionsInCacheProcessEvent(\n\tpayload: SyncSingleShopSectionsInCacheDTO\n) {\n\tconst syncSingleShopSectionsInCacheSyncEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SyncSingleShopSectionsInCacheEvent(payload);\n\tawait publishEvent(syncSingleShopSectionsInCacheSyncEvent);\n}\n\nexport async function publishAllCustomizedShopSectionsCacheProcessEvent(\n\tpayload: SynchronizeAllCustomizedShopSectionsCacheDTO\n) {\n\tconst SyncAllCustomizedShopSectionsCacheProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SynchronizeAllCustomizedShopSectionsCacheEvent({});\n\tawait publishEvent(SyncAllCustomizedShopSectionsCacheProcessEvent);\n}"]}
|
|
1
|
+
{"version":3,"file":"events-common-methods.js","sourceRoot":"/","sources":["utilities/events-common-methods.ts"],"names":[],"mappings":";;AAmDA,4CAyBC;AAwCD,sDAaC;AAKD,wDAKC;AAED,sDAcC;AAED,gFAIC;AAED,gHAMC;AAED,wGAIC;AAED,oGAIC;AAED,gHAMC;AAED,8GAMC;AAED,4FAKC;AAED,gIAMC;AAED,4GAMC;AAED,8GAMC;AAED,8JAMC;AAED,4JAMC;AAnPD,8CAAkD;AAGlD,6IAGkF;AAClF,iFAAoF;AACpF,+HAAuH;AACvH,uJAA6I;AAC7I,6HAG0E;AAC1E,6IAGkF;AAClF,2HAGyE;AACzE,+GAGmE;AACnE,iIAG4E;AAC5E,iIAG4E;AAC5E,2IAGiF;AACjF,yJAGgG;AAChG,uJAG+F;AAK/F,SAAgB,gBAAgB,CAC/B,MAAS,EACT,MAAS,EACT,OAAoB;IAEpB,MAAM,OAAO,GAAG,EAA6C,CAAC;IAE9D,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAClF,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAElF,MAAM,WAAW,GAAG,OAAO;QAC1B,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QACtB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC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BAAY,EAAC,wCAAwC,CAAC,CAAC;AAC9D,CAAC;AAEM,KAAK,UAAU,gDAAgD,CACrE,OAAyC;IAEzC,MAAM,sCAAsC,GAC3C,IAAI,6EAAkC,CAAC,OAAO,CAAC,CAAC;IACjD,MAAM,IAAA,oBAAY,EAAC,sCAAsC,CAAC,CAAC;AAC5D,CAAC;AAEM,KAAK,UAAU,iDAAiD,CACtE,OAAqD;IAErD,MAAM,8CAA8C,GACnD,IAAI,8FAA8C,CAAC,EAAE,CAAC,CAAC;IACxD,MAAM,IAAA,oBAAY,EAAC,8CAA8C,CAAC,CAAC;AACpE,CAAC;AAEM,KAAK,UAAU,yEAAyE,CAC9F,OAA8D;IAE9D,MAAM,6CAA6C,GAClD,IAAI,4FAA6C,CAAC,OAAO,CAAC,CAAC;IAC5D,MAAM,IAAA,oBAAY,EAAC,6CAA6C,CAAC,CAAC;AACnE,CAAC;AAEM,KAAK,UAAU,wEAAwE,CAC7F,OAAmE;IAEnE,MAAM,6DAA6D,GAClE,IAAI,0GAA4D,CAAC,OAAO,CAAC,CAAC;IAC3E,MAAM,IAAA,oBAAY,EAAC,6DAA6D,CAAC,CAAC;AACnF,CAAC","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { publishEvent } from '../libraries/event';\nimport { AdminLogsUpdatedFieldsType } from './enum';\nimport { BaseEvent } from '../libraries/event/BaseEvent';\nimport {\n\tMongoStreamsBatchProcessShopsDTO,\n\tMongoStreamsBatchProcessShopsEvent,\n} from '../libraries/event/events/mongo-stream-changes-batch-process-shops-event';\nimport { AdminActivityLogsEvent } from '../libraries/event/events/admin-logs-event';\nimport { ShopActiveTimingsBatchProcessEvent } from '../libraries/event/events/shop-active-timings-batch-process-event';\nimport { BulkUpdateShopsSearchFieldsBatchProcessEvent } from '../libraries/event/events/bulk-update-shops-search-fields-batch-process-event';\nimport {\n\tBulkUpdateShopsZoneStatusDTO,\n\tBulkUpdateShopsZoneStatusEvent,\n} from '../libraries/event/events/bulk-update-zone-status-in-shops-event';\nimport {\n\tSynchronizeAllProductsProductMarketingInfoDTO,\n\tSynchronizeAllProductsProductMarketingInfoEvent,\n} from '../libraries/event/events/sync-all-products-product-marketing-info-event';\nimport {\n\tSynchronizeAllShopsAvgPreparationTimeDTO,\n\tSynchronizeAllShopsAvgPreparationTimeEvent,\n} from '../libraries/event/events/sync-avg-prep-time-in-all-shops-event';\nimport {\n\tSyncSingleShopCacheDTO,\n\tSyncSingleShopInCacheEvent,\n} from '../libraries/event/events/sync-single-shop-in-cache-event';\nimport {\n\tSyncSingleShopOrderAgainCacheDTO,\n\tSyncSingleShopOrderAgainInCacheEvent,\n} from '../libraries/event/events/sync-order-again-sections-for-shop-event';\nimport {\n\tSyncSingleShopSectionsInCacheDTO,\n\tSyncSingleShopSectionsInCacheEvent,\n} from '../libraries/event/events/sync-single-shop-sections-in-cache-event';\nimport {\n\tSynchronizeAllCustomizedShopSectionsCacheDTO,\n\tSynchronizeAllCustomizedShopSectionsCacheEvent,\n} from '../libraries/event/events/sync-all-customized-shop-sections-cache-event';\nimport {\n\tSyncUserShopPunchMarketingHistoryInCacheEvent,\n\tSyncUserShopPunchMarketingHistoryInCacheValidationDTO,\n} from '../libraries/event/events/punch-marketing/sync-user-shop-punch-marketing-history-event';\nimport {\n\tSyncAllUserPunchMarketingHistoryWithPunchSectionInCacheDTO,\n\tSyncAllUserPunchMarketingHistoryWithPunchSectionInCacheEvent,\n} from '../libraries/event/events/punch-marketing/sync-all-user-punch-marketing-history-event';\n\n/**\n * Returns changed fields between two objects (shallow comparison).\n */\nexport function getChangedFields<T extends Record<string, any>>(\n\toldDoc: T,\n\tnewDoc: T,\n\tpayload?: Partial<T>\n): Record<keyof T, { old: any; new: any }> {\n\tconst changes = {} as Record<keyof T, { old: any; new: any }>;\n\n\tconst oldObj = typeof oldDoc.toObject === 'function' ? oldDoc.toObject() : oldDoc;\n\tconst newObj = typeof newDoc.toObject === 'function' ? newDoc.toObject() : newDoc;\n\n\tconst keysToCheck = payload\n\t\t? Object.keys(payload)\n\t\t: Array.from(new Set([...Object.keys(oldObj), ...Object.keys(newObj)]));\n\n\tfor (const key of keysToCheck) {\n\t\tconst oldValue = oldObj[key];\n\t\tconst newValue = newObj[key];\n\t\tconst cleanedOld = deepCleanSettingsValues(oldValue);\n\t\tconst cleanedNew = deepCleanSettingsValues(newValue);\n\t\tif (payload || JSON.stringify(cleanedOld) !== JSON.stringify(cleanedNew)) {\n\t\t\tchanges[key as keyof T] = { old: oldValue, new: newValue };\n\t\t}\n\t}\n\n\treturn changes;\n}\n\n// removes _id and deletedAt fields from objects, array of objects and prepares for data that has setting changes\nfunction deepCleanSettingsValues(value: any): any {\n\t// CASE 1: Array\n\tif (Array.isArray(value)) {\n\t\t// If array contains primitives → return as-is\n\t\tif (value.every(v => v === null || typeof v !== 'object')) {\n\t\t\treturn value;\n\t\t}\n\n\t\t// If array contains objects → deep clean each object\n\t\treturn value.map(item => deepCleanSettingsValues(item));\n\t}\n\n\t// CASE 2: Null → return as is\n\tif (value === null) return value;\n\n\t// CASE 3: Plain Object\n\tif (typeof value === 'object') {\n\t\tconst cleanedObj: any = {};\n\n\t\tfor (const key in value) {\n\t\t\tif (key === '_id' || key === 'deletedAt' || value[key] === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tcleanedObj[key] = deepCleanSettingsValues(value[key]);\n\t\t}\n\n\t\treturn cleanedObj;\n\t}\n\n\t// CASE 4: Primitive (string, number, boolean)\n\treturn value;\n}\n\n/**\n * Filters changed fields to only those that exist in the payload.\n */\nexport function filterRelevantChanges<T>(\n\tallChanges: Record<string, { old: any; new: any }>,\n\tpayload: Partial<T>\n): Record<string, { old: any; new: any }> {\n\treturn Object.keys(payload).reduce(\n\t\t(acc, key) => {\n\t\t\tif (allChanges[key]) {\n\t\t\t\tacc[key] = allChanges[key];\n\t\t\t}\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<string, { old: any; new: any }>\n\t);\n}\n\n/**\n * Extracts either 'old' or 'new' values from the changes object.\n */\nexport function extractChangedDocument(\n\tchanges: Record<string, { old: any; new: any }>,\n\ttype: 'old' | 'new'\n): Record<string, any> {\n\treturn Object.fromEntries(Object.entries(changes).map(([key, value]) => [key, value[type]]));\n}\n\nexport async function publishAdminLogsEvent(payload: {\n\tadmin: mongoose.Types.ObjectId;\n\tupdatedField: AdminLogsUpdatedFieldsType;\n\toldDoc: any;\n\tnewDoc: any;\n}) {\n\tconst { admin, updatedField, oldDoc, newDoc } = payload;\n\tconst adminActivityLogsEvent: BaseEvent<Record<string, unknown>> = new AdminActivityLogsEvent({\n\t\tadmin: admin,\n\t\tupdatedField: updatedField,\n\t\toldDocument: oldDoc,\n\t\tnewDocument: newDoc,\n\t});\n\tawait publishEvent(adminActivityLogsEvent);\n}\n\nexport async function publishShopActiveBatchProcessEvent() {\n\tconst shopActiveTimingsBatchProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew ShopActiveTimingsBatchProcessEvent({});\n\tawait publishEvent(shopActiveTimingsBatchProcessEvent);\n}\n\nexport async function publishMongodbStreamsChangesBatchProcessShopsEvent(\n\tpayload: MongoStreamsBatchProcessShopsDTO\n) {\n\tconst mongodbStreamsBatchProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew MongoStreamsBatchProcessShopsEvent(payload);\n\tawait publishEvent(mongodbStreamsBatchProcessEvent);\n}\n\nexport async function publishUpdateShopsSearchFieldsBulkProcessEvent(payload: any) {\n\tconst bulkUpdateShopsSearchFieldsBatchProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew BulkUpdateShopsSearchFieldsBatchProcessEvent(payload);\n\tawait publishEvent(bulkUpdateShopsSearchFieldsBatchProcessEvent);\n}\n\nexport async function publishBulkUpdateShopsZoneStatusProcessEvent(payload: BulkUpdateShopsZoneStatusDTO) {\n\tconst shopsZoneStatusBatchProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew BulkUpdateShopsZoneStatusEvent(payload);\n\tawait publishEvent(shopsZoneStatusBatchProcessEvent);\n}\n\nexport async function publishAllProductsProductMarketingInfoProcessEvent(\n\tpayload: SynchronizeAllProductsProductMarketingInfoDTO\n) {\n\tconst SyncAllProductsProductMarketingInfoProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SynchronizeAllProductsProductMarketingInfoEvent({});\n\tawait publishEvent(SyncAllProductsProductMarketingInfoProcessEvent);\n}\n\nexport async function publishAllShopsAvgPreperationTimeSyncProcessEvent(\n\tpayload: SynchronizeAllShopsAvgPreparationTimeDTO\n) {\n\tconst SyncAllShopsAvgPreperationTimeSyncProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SynchronizeAllShopsAvgPreparationTimeEvent({});\n\tawait publishEvent(SyncAllShopsAvgPreperationTimeSyncProcessEvent);\n}\n\nexport async function publishSyncSingleShopInCacheProcessEvent(payload: SyncSingleShopCacheDTO) {\n\tconst syncSingleShopCacheSyncEvent: BaseEvent<Record<string, unknown>> = new SyncSingleShopInCacheEvent(\n\t\tpayload\n\t);\n\tawait publishEvent(syncSingleShopCacheSyncEvent);\n}\n\nexport async function publishSyncSingleShopOrderAgainSectionsInCacheProcessEvent(\n\tpayload: SyncSingleShopOrderAgainCacheDTO\n) {\n\tconst syncSingleShopOrderAgainInCacheSyncEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SyncSingleShopOrderAgainInCacheEvent(payload);\n\tawait publishEvent(syncSingleShopOrderAgainInCacheSyncEvent);\n}\n\nexport async function publishSyncSingleShopSectionsInCacheProcessEvent(\n\tpayload: SyncSingleShopSectionsInCacheDTO\n) {\n\tconst syncSingleShopSectionsInCacheSyncEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SyncSingleShopSectionsInCacheEvent(payload);\n\tawait publishEvent(syncSingleShopSectionsInCacheSyncEvent);\n}\n\nexport async function publishAllCustomizedShopSectionsCacheProcessEvent(\n\tpayload: SynchronizeAllCustomizedShopSectionsCacheDTO\n) {\n\tconst SyncAllCustomizedShopSectionsCacheProcessEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SynchronizeAllCustomizedShopSectionsCacheEvent({});\n\tawait publishEvent(SyncAllCustomizedShopSectionsCacheProcessEvent);\n}\n\nexport async function publishSyncUserShopPunchMarketingHistoryWithPunchSectionCacheProcessEvent(\n\tpayload: SyncUserShopPunchMarketingHistoryInCacheValidationDTO\n) {\n\tconst syncUserShopPunchMarketingHistoryInCacheEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SyncUserShopPunchMarketingHistoryInCacheEvent(payload);\n\tawait publishEvent(syncUserShopPunchMarketingHistoryInCacheEvent);\n}\n\nexport async function publishSyncAllUserPunchMarketingHistoryWithPunchSectionCacheProcessEvent(\n\tpayload: SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheDTO\n) {\n\tconst syncAllUserPunchMarketingHistoryWithPunchSectionsInCacheEvent: BaseEvent<Record<string, unknown>> =\n\t\tnew SyncAllUserPunchMarketingHistoryWithPunchSectionInCacheEvent(payload);\n\tawait publishEvent(syncAllUserPunchMarketingHistoryWithPunchSectionsInCacheEvent);\n}\n"]}
|