@lyxa.ai/core 1.1.21 → 1.1.23
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/index.d.ts +3 -3
- package/dist/libraries/event/index.js +18 -61
- package/dist/libraries/event/index.js.map +1 -1
- package/dist/libraries/mongo/models/banner.model.js +3 -3
- package/dist/libraries/mongo/models/banner.model.js.map +1 -1
- package/dist/libraries/mongo/models/cancellation-reason.model.js +3 -3
- package/dist/libraries/mongo/models/cancellation-reason.model.js.map +1 -1
- package/dist/libraries/mongo/models/cart.model.js +2 -2
- package/dist/libraries/mongo/models/cart.model.js.map +1 -1
- package/dist/libraries/mongo/models/category.model.js +2 -19
- package/dist/libraries/mongo/models/category.model.js.map +1 -1
- package/dist/libraries/mongo/models/dish.model.js +2 -2
- package/dist/libraries/mongo/models/dish.model.js.map +1 -1
- package/dist/libraries/mongo/models/faq.model.js +2 -2
- package/dist/libraries/mongo/models/faq.model.js.map +1 -1
- package/dist/libraries/mongo/models/filter-container.model.js +3 -3
- package/dist/libraries/mongo/models/filter-container.model.js.map +1 -1
- package/dist/libraries/mongo/models/finance-settlement.model.js +2 -2
- package/dist/libraries/mongo/models/finance-settlement.model.js.map +1 -1
- package/dist/libraries/mongo/models/list-container.model.js +3 -3
- package/dist/libraries/mongo/models/list-container.model.js.map +1 -1
- package/dist/libraries/mongo/models/product.model.d.ts +1 -0
- package/dist/libraries/mongo/models/product.model.js +13 -6
- package/dist/libraries/mongo/models/product.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop-category.model.js +2 -2
- package/dist/libraries/mongo/models/shop-category.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop.model.js +2 -2
- package/dist/libraries/mongo/models/shop.model.js.map +1 -1
- package/dist/libraries/mongo/models/support-reason.model.js +3 -3
- package/dist/libraries/mongo/models/support-reason.model.js.map +1 -1
- package/dist/libraries/mongo/models/tag.model.js +3 -3
- package/dist/libraries/mongo/models/tag.model.js.map +1 -1
- package/dist/libraries/mongo/models/user-app-section-setting.model.js +3 -3
- package/dist/libraries/mongo/models/user-app-section-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/user.model.d.ts +1 -1
- package/dist/libraries/mongo/plugins/normalize-field.plugin.d.ts +4 -0
- package/dist/libraries/mongo/plugins/normalize-field.plugin.js +42 -0
- package/dist/libraries/mongo/plugins/normalize-field.plugin.js.map +1 -0
- package/dist/libraries/mongo/utilities/{shopHooks.js → shop.hooks.js} +3 -3
- package/dist/libraries/mongo/utilities/shop.hooks.js.map +1 -0
- package/dist/libraries/mongo/utilities/{sortingOrderHooks.js → sorting-order.hooks.js} +1 -1
- package/dist/libraries/mongo/utilities/sorting-order.hooks.js.map +1 -0
- package/dist/libraries/mongo/utilities/{uniqueIdHooks.js → unique-id.hooks.js} +1 -1
- package/dist/libraries/mongo/utilities/unique-id.hooks.js.map +1 -0
- package/dist/libraries/socket/BaseSocketEvent.d.ts +4 -1
- package/dist/libraries/socket/BaseSocketEvent.js +4 -4
- package/dist/libraries/socket/BaseSocketEvent.js.map +1 -1
- package/dist/libraries/socket/PushNotificationEvent.d.ts +13 -0
- package/dist/libraries/socket/PushNotificationEvent.js +20 -0
- package/dist/libraries/socket/PushNotificationEvent.js.map +1 -0
- package/dist/libraries/socket/core/socket-event-consumer.d.ts +1 -0
- package/dist/libraries/socket/core/socket-event-consumer.js +27 -0
- package/dist/libraries/socket/core/socket-event-consumer.js.map +1 -0
- package/dist/libraries/socket/core/socket-event-publisher.d.ts +4 -0
- package/dist/libraries/socket/core/socket-event-publisher.js +68 -0
- package/dist/libraries/socket/core/socket-event-publisher.js.map +1 -0
- package/dist/libraries/socket/core/socket-event-registry.d.ts +1 -1
- package/dist/libraries/socket/core/socket-event-registry.js +1 -1
- package/dist/libraries/socket/core/socket-event-registry.js.map +1 -1
- package/dist/libraries/socket/{socket-event-registry.map.d.ts → core/socket-event-registry.map.d.ts} +33 -19
- package/dist/libraries/socket/core/socket-event-registry.map.js +33 -0
- package/dist/libraries/socket/core/socket-event-registry.map.js.map +1 -0
- package/dist/libraries/socket/events/chatlist-message-send.socket.event.d.ts +5 -4
- package/dist/libraries/socket/events/chatlist-message-send.socket.event.js +10 -7
- package/dist/libraries/socket/events/chatlist-message-send.socket.event.js.map +1 -1
- package/dist/libraries/socket/events/chatroom-message-send.socket.event.d.ts +10 -5
- package/dist/libraries/socket/events/chatroom-message-send.socket.event.js +17 -7
- package/dist/libraries/socket/events/chatroom-message-send.socket.event.js.map +1 -1
- package/dist/libraries/socket/events/notification.socket.event.d.ts +25 -0
- package/dist/libraries/socket/events/notification.socket.event.js +22 -0
- package/dist/libraries/socket/events/notification.socket.event.js.map +1 -0
- package/dist/libraries/socket/events/ticket-assign.socket.event.d.ts +5 -4
- package/dist/libraries/socket/events/ticket-assign.socket.event.js +4 -4
- package/dist/libraries/socket/events/ticket-assign.socket.event.js.map +1 -1
- package/dist/libraries/socket/events/ticket-unassign.socket.event.d.ts +5 -4
- package/dist/libraries/socket/events/ticket-unassign.socket.event.js +7 -4
- package/dist/libraries/socket/events/ticket-unassign.socket.event.js.map +1 -1
- package/dist/libraries/trpc/middlewares/createSocketSubscriptionProcedure.d.ts +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/enum.d.ts +5 -1
- package/dist/types/utilities/enum.js +6 -1
- package/dist/types/utilities/enum.js.map +1 -1
- package/dist/types/utilities/validation/common-validation.d.ts +78 -2
- package/dist/types/utilities/validation/global-validation.d.ts +38 -14
- package/dist/utilities/enum.d.ts +5 -1
- package/dist/utilities/enum.js +6 -1
- package/dist/utilities/enum.js.map +1 -1
- package/dist/utilities/normalize.d.ts +1 -0
- package/dist/utilities/normalize.js +7 -0
- package/dist/utilities/normalize.js.map +1 -1
- package/dist/utilities/validation/common-validation.d.ts +78 -2
- package/dist/utilities/validation/global-validation.d.ts +38 -14
- package/package.json +1 -1
- package/dist/libraries/mongo/utilities/shopHooks.js.map +0 -1
- package/dist/libraries/mongo/utilities/sortingOrderHooks.js.map +0 -1
- package/dist/libraries/mongo/utilities/uniqueIdHooks.js.map +0 -1
- package/dist/libraries/socket/socket-event-registry.map.js +0 -28
- package/dist/libraries/socket/socket-event-registry.map.js.map +0 -1
- /package/dist/libraries/mongo/utilities/{shopHooks.d.ts → shop.hooks.d.ts} +0 -0
- /package/dist/libraries/mongo/utilities/{sortingOrderHooks.d.ts → sorting-order.hooks.d.ts} +0 -0
- /package/dist/libraries/mongo/utilities/{uniqueIdHooks.d.ts → unique-id.hooks.d.ts} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import amqp from 'amqplib';
|
|
2
2
|
import { BaseEvent } from './BaseEvent';
|
|
3
|
-
|
|
3
|
+
export declare const EXCHANGE_NAME = "lyxa.events";
|
|
4
|
+
export declare const INSTANCE_ROUTE_PREFIX = "instance";
|
|
4
5
|
export declare function initEventBus(rabbitUrl: string): Promise<void>;
|
|
6
|
+
export declare function getChannel(): amqp.Channel;
|
|
5
7
|
export declare function publishEvent<TPayload extends Record<string, unknown>>(event: BaseEvent<TPayload>): Promise<void>;
|
|
6
8
|
export declare function subscribeToEvent(eventId: string, onMessage: (payload: any) => Promise<void>): Promise<void>;
|
|
7
|
-
export declare function subscribeToSocketEvent(): Promise<amqp.Channel>;
|
|
8
|
-
export declare function publishSocketEvent(event: BaseSocketEvent<any, any>, recipients: string[]): Promise<void>;
|
|
9
9
|
export declare function closeEventBus(): Promise<void>;
|
|
@@ -3,102 +3,59 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.INSTANCE_ROUTE_PREFIX = exports.EXCHANGE_NAME = void 0;
|
|
6
7
|
exports.initEventBus = initEventBus;
|
|
8
|
+
exports.getChannel = getChannel;
|
|
7
9
|
exports.publishEvent = publishEvent;
|
|
8
10
|
exports.subscribeToEvent = subscribeToEvent;
|
|
9
|
-
exports.subscribeToSocketEvent = subscribeToSocketEvent;
|
|
10
|
-
exports.publishSocketEvent = publishSocketEvent;
|
|
11
11
|
exports.closeEventBus = closeEventBus;
|
|
12
12
|
const amqplib_1 = __importDefault(require("amqplib"));
|
|
13
13
|
const instance_utils_1 = require("../../utilities/instance.utils");
|
|
14
|
-
const index_1 = require("../../index");
|
|
15
|
-
const local_subscription_registry_1 = require("../socket/core/local-subscription-registry");
|
|
16
|
-
const socket_redis_connections_1 = require("../socket/core/socket-redis-connections");
|
|
17
14
|
let connection;
|
|
18
15
|
let channel;
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
exports.EXCHANGE_NAME = 'lyxa.events';
|
|
17
|
+
exports.INSTANCE_ROUTE_PREFIX = 'instance';
|
|
21
18
|
async function initEventBus(rabbitUrl) {
|
|
22
19
|
connection = await amqplib_1.default.connect(rabbitUrl);
|
|
23
20
|
channel = await connection.createChannel();
|
|
24
|
-
await channel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });
|
|
21
|
+
await channel.assertExchange(exports.EXCHANGE_NAME, 'topic', { durable: true });
|
|
25
22
|
console.log(`EventBus initialized with instance ID: ${(0, instance_utils_1.getInstanceId)()}`);
|
|
26
23
|
}
|
|
27
|
-
|
|
24
|
+
function getChannel() {
|
|
28
25
|
if (!channel)
|
|
29
26
|
throw new Error('Channel not initialized. Call initEventBus first.');
|
|
27
|
+
return channel;
|
|
28
|
+
}
|
|
29
|
+
async function publishEvent(event) {
|
|
30
|
+
const ch = getChannel();
|
|
30
31
|
const messageBuffer = Buffer.from(JSON.stringify(event.payload));
|
|
31
|
-
|
|
32
|
+
ch.publish(exports.EXCHANGE_NAME, event.eventId, messageBuffer, {
|
|
32
33
|
contentType: 'application/json',
|
|
33
34
|
});
|
|
34
35
|
console.log(`Published event [${event.eventId}] with payload`, event.payload);
|
|
35
36
|
}
|
|
36
37
|
async function subscribeToEvent(eventId, onMessage) {
|
|
37
|
-
|
|
38
|
-
throw new Error('Channel not initialized. Call initEventBus first.');
|
|
38
|
+
const ch = getChannel();
|
|
39
39
|
const queueName = `${eventId}-${(0, instance_utils_1.getInstanceId)()}`;
|
|
40
|
-
await
|
|
40
|
+
await ch.assertQueue(queueName, {
|
|
41
41
|
durable: false,
|
|
42
42
|
exclusive: true,
|
|
43
43
|
autoDelete: true,
|
|
44
44
|
});
|
|
45
|
-
await
|
|
46
|
-
await
|
|
45
|
+
await ch.bindQueue(queueName, exports.EXCHANGE_NAME, eventId);
|
|
46
|
+
await ch.consume(queueName, async (msg) => {
|
|
47
47
|
if (msg !== null) {
|
|
48
|
-
const
|
|
49
|
-
const payload = JSON.parse(payloadString);
|
|
48
|
+
const payload = JSON.parse(msg.content.toString());
|
|
50
49
|
try {
|
|
51
50
|
await onMessage(payload);
|
|
52
|
-
|
|
51
|
+
ch.ack(msg);
|
|
53
52
|
}
|
|
54
53
|
catch (err) {
|
|
55
54
|
console.error(`Error handling event [${eventId}] on instance [${(0, instance_utils_1.getInstanceId)()}]`, err);
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
}, { noAck: false });
|
|
59
|
-
console.log(`Subscribed to event [${eventId}] on queue [${queueName}]
|
|
60
|
-
}
|
|
61
|
-
async function subscribeToSocketEvent() {
|
|
62
|
-
const queueName = `socket-events-${(0, instance_utils_1.getInstanceId)()}`;
|
|
63
|
-
await channel.assertQueue(queueName, { durable: true });
|
|
64
|
-
await channel.bindQueue(queueName, EXCHANGE_NAME, `instance.${(0, instance_utils_1.getInstanceId)()}`);
|
|
65
|
-
await channel.consume(queueName, msg => {
|
|
66
|
-
if (!msg)
|
|
67
|
-
return;
|
|
68
|
-
try {
|
|
69
|
-
const { localKey, payload, recipient } = JSON.parse(msg.content.toString('utf8'));
|
|
70
|
-
local_subscription_registry_1.LocalSubs.emit(recipient, localKey, payload);
|
|
71
|
-
channel.ack(msg);
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
console.error('Failed to handle instance event', e);
|
|
75
|
-
channel.nack(msg, false, false);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return channel;
|
|
79
|
-
}
|
|
80
|
-
async function publishSocketEvent(event, recipients) {
|
|
81
|
-
const redisService = (0, index_1.getLibraries)().getRedisService();
|
|
82
|
-
const localKey = event.getSubscriptionKey();
|
|
83
|
-
const payload = event.payload();
|
|
84
|
-
for (const recipient of recipients) {
|
|
85
|
-
const isSub = await (0, socket_redis_connections_1.isEntitySubscribed)(recipient, localKey);
|
|
86
|
-
if (!isSub) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
const instanceNames = await redisService.getSetMembers((0, socket_redis_connections_1.kEntityInstances)(recipient));
|
|
90
|
-
if (!instanceNames.length) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
for (const instanceName of instanceNames) {
|
|
94
|
-
const routingKey = `${INSTANCE_ROUTE_PREFIX}.${instanceName}`;
|
|
95
|
-
const messageBuffer = Buffer.from(JSON.stringify({ localKey, payload, recipient }), 'utf8');
|
|
96
|
-
channel.publish(EXCHANGE_NAME, routingKey, messageBuffer, {
|
|
97
|
-
contentType: 'application/json',
|
|
98
|
-
persistent: true,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}
|
|
58
|
+
console.log(`Subscribed to event [${eventId}] on queue [${queueName}]`);
|
|
102
59
|
}
|
|
103
60
|
async function closeEventBus() {
|
|
104
61
|
if (channel)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/event/index.ts"],"names":[],"mappings":";;;;;;AASA,oCAKC;AAED,gCAGC;AAED,oCASC;AAED,4CAgCC;AAED,sCAIC;AAtED,sDAA2B;AAE3B,mEAA+D;AAE/D,IAAI,UAA6B,CAAC;AAClC,IAAI,OAAqB,CAAC;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AAS,EAAE,IAAI;QACf,UAAU,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,qBAAa,EAAE,OAAO,CAAC,CAAC;IAEtD,MAAM,EAAE,CAAC,OAAO,CACf,SAAS,EACT,KAAK,EAAC,GAAG,EAAC,EAAE;QACX,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YACnD,IAAI,CAAC;gBACJ,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC;gBACzB,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACb,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,OAAO,CAAC,KAAK,CAAC,yBAAyB,OAAO,kBAAkB,IAAA,8BAAa,GAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YAC1F,CAAC;QACF,CAAC;IACF,CAAC,EACD,EAAE,KAAK,EAAE,KAAK,EAAE,CAChB,CAAC;IAEF,OAAO,CAAC,GAAG,CAAC,wBAAwB,OAAO,eAAe,SAAS,GAAG,CAAC,CAAC;AACzE,CAAC;AAEM,KAAK,UAAU,aAAa;IAClC,IAAI,OAAO;QAAE,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACnC,IAAI,UAAU;QAAE,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAA,8BAAa,GAAE,GAAG,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import amqp from 'amqplib';\nimport { BaseEvent } from './BaseEvent';\nimport { getInstanceId } from '../../utilities/instance.utils';\n\nlet connection: amqp.ChannelModel;\nlet channel: amqp.Channel;\nexport const EXCHANGE_NAME = 'lyxa.events';\nexport const INSTANCE_ROUTE_PREFIX = 'instance'; // routing key: instance.{instanceName}.{eventType}\n\nexport async function initEventBus(rabbitUrl: string) {\n\tconnection = await amqp.connect(rabbitUrl);\n\tchannel = await connection.createChannel();\n\tawait channel.assertExchange(EXCHANGE_NAME, 'topic', { durable: true });\n\tconsole.log(`EventBus initialized with instance ID: ${getInstanceId()}`);\n}\n\nexport function getChannel(): amqp.Channel {\n\tif (!channel) throw new Error('Channel not initialized. Call initEventBus first.');\n\treturn channel;\n}\n\nexport async function publishEvent<TPayload extends Record<string, unknown>>(\n\tevent: BaseEvent<TPayload>\n): Promise<void> {\n\tconst ch = getChannel();\n\tconst messageBuffer = Buffer.from(JSON.stringify(event.payload));\n\tch.publish(EXCHANGE_NAME, event.eventId, messageBuffer, {\n\t\tcontentType: 'application/json',\n\t});\n\tconsole.log(`Published event [${event.eventId}] with payload`, event.payload);\n}\n\nexport async function subscribeToEvent(\n\teventId: string,\n\tonMessage: (payload: any) => Promise<void>\n): Promise<void> {\n\tconst ch = getChannel();\n\tconst queueName = `${eventId}-${getInstanceId()}`;\n\n\tawait ch.assertQueue(queueName, {\n\t\tdurable: false,\n\t\texclusive: true,\n\t\tautoDelete: true,\n\t});\n\n\tawait ch.bindQueue(queueName, EXCHANGE_NAME, eventId);\n\n\tawait ch.consume(\n\t\tqueueName,\n\t\tasync msg => {\n\t\t\tif (msg !== null) {\n\t\t\t\tconst payload = JSON.parse(msg.content.toString());\n\t\t\t\ttry {\n\t\t\t\t\tawait onMessage(payload);\n\t\t\t\t\tch.ack(msg);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tconsole.error(`Error handling event [${eventId}] on instance [${getInstanceId()}]`, err);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t{ noAck: false }\n\t);\n\n\tconsole.log(`Subscribed to event [${eventId}] on queue [${queueName}]`);\n}\n\nexport async function closeEventBus(): Promise<void> {\n\tif (channel) await channel.close();\n\tif (connection) await connection.close();\n\tconsole.log(`EventBus closed for instance [${getInstanceId()}]`);\n}"]}
|
|
@@ -18,7 +18,7 @@ const product_model_1 = require("./product.model");
|
|
|
18
18
|
const zone_model_1 = require("./zone.model");
|
|
19
19
|
const list_container_model_1 = require("./list-container.model");
|
|
20
20
|
const _1 = require(".");
|
|
21
|
-
const
|
|
21
|
+
const sorting_order_hooks_1 = require("../utilities/sorting-order.hooks");
|
|
22
22
|
let Banner = class Banner extends defaultClasses_1.TimeStamps {
|
|
23
23
|
title;
|
|
24
24
|
image;
|
|
@@ -95,11 +95,11 @@ __decorate([
|
|
|
95
95
|
exports.Banner = Banner = __decorate([
|
|
96
96
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'banners' } }),
|
|
97
97
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
98
|
-
await
|
|
98
|
+
await sorting_order_hooks_1.handlePreSaveForSortingWithStatus.call(this, _1.BannerModel, { itemType: this.itemType });
|
|
99
99
|
next();
|
|
100
100
|
}),
|
|
101
101
|
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
102
|
-
await
|
|
102
|
+
await sorting_order_hooks_1.handlePreUpdateForSortingWithStatus.call(this, _1.BannerModel, ['itemType']);
|
|
103
103
|
next();
|
|
104
104
|
}),
|
|
105
105
|
(0, typegoose_1.index)({ title: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner.model.js","sourceRoot":"/","sources":["libraries/mongo/models/banner.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAOiC;AACjC,6CAAoC;AACpC,mDAA0C;AAC1C,6CAAoC;AACpC,iEAAuD;AACvD,wBAAgC;AAEhC,
|
|
1
|
+
{"version":3,"file":"banner.model.js","sourceRoot":"/","sources":["libraries/mongo/models/banner.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAOiC;AACjC,6CAAoC;AACpC,mDAA0C;AAC1C,6CAAoC;AACpC,iEAAuD;AACvD,wBAAgC;AAE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AAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;GACvE,MAAM,CA0ClB","sourcesContent":["import { index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport {\n\tBannerClickType,\n\tBannerLinkType,\n\tBannerUserType,\n\tItemType,\n\tStatus,\n\tUserAppSectionItemType,\n} from '../../../utilities/enum';\nimport { Shop } from './shop.model';\nimport { Product } from './product.model';\nimport { Zone } from './zone.model';\nimport { ListContainer } from './list-container.model';\nimport { BannerModel } from '.';\nimport { Query } from 'mongoose';\nimport {\n\thandlePreSaveForSortingWithStatus,\n\thandlePreUpdateForSortingWithStatus,\n} from '../utilities/sorting-order.hooks';\n\n@modelOptions({ schemaOptions: { collection: 'banners' } })\n@pre<Banner>('save', async function (next) {\n\tawait handlePreSaveForSortingWithStatus.call(this, BannerModel, { itemType: this.itemType });\n\n\tnext();\n})\n@pre<Banner>('findOneAndUpdate', async function (this: Query<any, Banner>, next) {\n\tawait handlePreUpdateForSortingWithStatus.call(this, BannerModel, ['itemType']);\n\n\tnext();\n})\n@index({ title: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\nexport class Banner extends TimeStamps {\n\t@prop({ required: true, type: String, trim: true, maxlength: 50 })\n\tpublic title!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic image!: string;\n\n\t@prop({ required: true, type: String, enum: UserAppSectionItemType })\n\tpublic itemType!: UserAppSectionItemType;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: String, enum: BannerUserType, default: BannerUserType.ALL })\n\tpublic visibility?: BannerUserType;\n\n\t@prop({ ref: () => Zone, default: [] })\n\tpublic zones?: Ref<Zone>[];\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isClickable?: boolean;\n\n\t@prop({ type: String, enum: BannerClickType })\n\tpublic clickType?: BannerClickType;\n\n\t@prop({ type: String, enum: BannerLinkType })\n\tpublic linkType?: BannerLinkType;\n\n\t@prop({ type: String, trim: true })\n\tpublic link?: string;\n\n\t@prop({ ref: () => Shop })\n\tpublic shop?: Ref<Shop>;\n\n\t@prop({ ref: () => Product })\n\tpublic product?: Ref<Product>;\n\n\t@prop({ ref: () => ListContainer })\n\tpublic listContainer?: Ref<ListContainer>;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -14,7 +14,7 @@ const typegoose_1 = require("@typegoose/typegoose");
|
|
|
14
14
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
const _1 = require(".");
|
|
17
|
-
const
|
|
17
|
+
const sorting_order_hooks_1 = require("../utilities/sorting-order.hooks");
|
|
18
18
|
let CancellationReason = class CancellationReason extends defaultClasses_1.TimeStamps {
|
|
19
19
|
reason;
|
|
20
20
|
reasonType;
|
|
@@ -41,13 +41,13 @@ __decorate([
|
|
|
41
41
|
exports.CancellationReason = CancellationReason = __decorate([
|
|
42
42
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'cancellationReasons' } }),
|
|
43
43
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
44
|
-
await
|
|
44
|
+
await sorting_order_hooks_1.handlePreSaveForSortingWithStatus.call(this, _1.CancellationReasonModel, {
|
|
45
45
|
reasonType: this.reasonType,
|
|
46
46
|
});
|
|
47
47
|
next();
|
|
48
48
|
}),
|
|
49
49
|
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
50
|
-
await
|
|
50
|
+
await sorting_order_hooks_1.handlePreUpdateForSortingWithStatus.call(this, _1.CancellationReasonModel, ['reasonType']);
|
|
51
51
|
next();
|
|
52
52
|
}),
|
|
53
53
|
(0, typegoose_1.index)({ reason: 1, reasonType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancellation-reason.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cancellation-reason.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,kDAA6E;AAE7E,wBAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"cancellation-reason.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cancellation-reason.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,kDAA6E;AAE7E,wBAA4C;AAC5C,0EAG0C;AAgBnC,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,2BAAU;IAE1C,MAAM,CAAU;IAGhB,UAAU,CAA8B;IAGxC,MAAM,CAAU;IAGhB,YAAY,CAAU;CAC7B,CAAA;AAZY,gDAAkB;AAEvB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;kDACF;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,iCAA0B,EAAE,CAAC;;sDACZ;AAGxC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,aAAM,EAAE,CAAC;;kDAChB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;wDACM;6BAXjB,kBAAkB;IAd9B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,qBAAqB,EAAE,EAAE,CAAC;IACtE,IAAA,eAAG,EAAqB,MAAM,EAAE,KAAK,WAAW,IAAI;QACpD,MAAM,uDAAiC,CAAC,IAAI,CAAC,IAAI,EAAE,0BAAuB,EAAE;YAC3E,UAAU,EAAE,IAAI,CAAC,UAAU;SAC3B,CAAC,CAAC;QAEH,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,eAAG,EAAqB,kBAAkB,EAAE,KAAK,WAAiD,IAAI;QACtG,MAAM,yDAAmC,CAAC,IAAI,CAAC,IAAI,EAAE,0BAAuB,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;QAE9F,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,iBAAK,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;GACvF,kBAAkB,CAY9B","sourcesContent":["import { modelOptions, prop, pre, index } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CancellationReasonTypeEnum, Status } from '../../../utilities/enum';\nimport { Query } from 'mongoose';\nimport { CancellationReasonModel } from '.';\nimport {\n\thandlePreSaveForSortingWithStatus,\n\thandlePreUpdateForSortingWithStatus,\n} from '../utilities/sorting-order.hooks';\n\n@modelOptions({ schemaOptions: { collection: 'cancellationReasons' } })\n@pre<CancellationReason>('save', async function (next) {\n\tawait handlePreSaveForSortingWithStatus.call(this, CancellationReasonModel, {\n\t\treasonType: this.reasonType,\n\t});\n\n\tnext();\n})\n@pre<CancellationReason>('findOneAndUpdate', async function (this: Query<any, CancellationReason>, next) {\n\tawait handlePreUpdateForSortingWithStatus.call(this, CancellationReasonModel, ['reasonType']);\n\n\tnext();\n})\n@index({ reason: 1, reasonType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\nexport class CancellationReason extends TimeStamps {\n\t@prop({ required: true })\n\tpublic reason!: string;\n\n\t@prop({ required: true, enum: CancellationReasonTypeEnum })\n\tpublic reasonType!: CancellationReasonTypeEnum;\n\n\t@prop({ required: true, enum: Status })\n\tpublic status!: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -18,7 +18,7 @@ const enum_1 = require("../../../utilities/enum");
|
|
|
18
18
|
const address_model_1 = require("./shared/address.model");
|
|
19
19
|
const user_model_1 = require("./user.model");
|
|
20
20
|
const line_item_model_1 = require("./line-item.model");
|
|
21
|
-
const
|
|
21
|
+
const unique_id_hooks_1 = require("../utilities/unique-id.hooks");
|
|
22
22
|
const _1 = require(".");
|
|
23
23
|
const charge_model_1 = require("./embedded/charge.model");
|
|
24
24
|
class ShopSnap {
|
|
@@ -178,7 +178,7 @@ exports.Cart = Cart = __decorate([
|
|
|
178
178
|
},
|
|
179
179
|
}),
|
|
180
180
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
181
|
-
await
|
|
181
|
+
await unique_id_hooks_1.handlePreSaveForUniqueId.call(this, _1.CartModel, 'cartId');
|
|
182
182
|
next();
|
|
183
183
|
})
|
|
184
184
|
], Cart);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cart.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAqF;AACrF,6CAAoC;AACpC,iDAAwC;AACxC,4EAAqE;AACrE,kDAA8F;AAC9F,0DAAsE;AAEtE,6CAAoC;AACpC,uDAA6C;AAC7C,
|
|
1
|
+
{"version":3,"file":"cart.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cart.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAqF;AACrF,6CAAoC;AACpC,iDAAwC;AACxC,4EAAqE;AACrE,kDAA8F;AAC9F,0DAAsE;AAEtE,6CAAoC;AACpC,uDAA6C;AAC7C,kEAAwE;AACxE,wBAA8B;AAC9B,0DAAiD;AAEjD,MAAa,QAAQ;IAEb,IAAI,CAAU;IAGd,UAAU,CAAc;IAGxB,MAAM,CAAU;IAGhB,QAAQ,CAAY;IAGpB,OAAO,CAAW;IAGlB,IAAI,CAAU;IAGd,cAAc,CAAW;IAGzB,sBAAsB,CAAU;CACvC;AAxBD,4BAwBC;AAtBO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,E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S,EAAE,IAAI;SACf;KACD,CACD;IACA,IAAA,eAAG,EAAO,MAAM,EAAE,KAAK,WAAW,IAAI;QAEtC,MAAM,0CAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,YAAS,EAAE,QAAQ,CAAC,CAAC;QAE/D,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,IAAI,CAyDhB","sourcesContent":["import { prop, Ref, index, modelOptions, Severity, pre } from '@typegoose/typegoose';\nimport { Shop } from './shop.model';\nimport { Parent } from './parent.model';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CartStatus, ChargeType, ItemType, PaymentPreference } from '../../../utilities/enum';\nimport { Address, RegularOrderAddress } from './shared/address.model';\nimport { Coupon } from './coupon.model';\nimport { User } from './user.model';\nimport { LineItem } from './line-item.model';\nimport { handlePreSaveForUniqueId } from '../utilities/unique-id.hooks';\nimport { CartModel } from '.';\nimport { Charge } from './embedded/charge.model';\n\nexport class ShopSnap {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: String, enum: ChargeType, default: ChargeType.CUSTOM })\n\tpublic chargeType!: ChargeType;\n\n\t@prop({ required: true, type: Charge })\n\tpublic charge!: Charge;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ required: true, type: Address })\n\tpublic address!: Address;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isShopDelivery?: boolean;\n\n\t@prop({ type: Number, default: 10 })\n\tpublic defaultPreparationTime?: number;\n}\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'carts',\n\t\ttoJSON: { virtuals: true },\n\t\ttoObject: { virtuals: true },\n\t},\n\toptions: {\n\t\tallowMixed: Severity.ALLOW,\n\t},\n})\n@index({ user: 1 })\n@index({ shop: 1 })\n@index({ status: 1 })\n@index(\n\t{ user: 1, shop: 1 },\n\t{\n\t\tunique: true,\n\t\tpartialFilterExpression: {\n\t\t\tstatus: { $in: [CartStatus.ACTIVE, CartStatus.LOCKED] },\n\t\t\tdeletedAt: null,\n\t\t},\n\t}\n)\n@pre<Cart>('save', async function (next) {\n\t// Generate unique id if not exists\n\tawait handlePreSaveForUniqueId.call(this, CartModel, 'cartId');\n\n\tnext();\n})\nexport class Cart extends TimeStamps {\n\t@prop({ type: String, unique: true, index: true })\n\tpublic cartId: string;\n\n\t@prop({ trim: true, maxlength: 100 })\n\tpublic title?: string;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic exchangeRate?: number;\n\n\t@prop({ type: Number, default: 0.01 })\n\tpublic roundTo?: number;\n\n\t@prop({ type: Number, default: 1000 })\n\tpublic secondaryRoundTo?: number;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ required: true, ref: () => Parent })\n\tpublic parent: Ref<Parent>;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ type: ShopSnap })\n\tpublic shopSnap?: ShopSnap;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isGroupOrder?: boolean;\n\n\t@prop({ type: String, enum: PaymentPreference })\n\tpublic paymentPreference?: PaymentPreference;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic spendingLimitForGuest?: number;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic secondarySpendingLimitForGuest?: number;\n\n\t@prop({\n\t\tenum: CartStatus,\n\t\ttype: String,\n\t\tdefault: CartStatus.ACTIVE,\n\t\trequired: true,\n\t})\n\tpublic status!: CartStatus;\n\n\t@prop({ type: String, trim: true })\n\tpublic couponCode?: string;\n\n\t@prop({\n\t\tref: () => LineItem,\n\t\tforeignField: 'cart',\n\t\tlocalField: '_id',\n\t})\n\tpublic lineItems: Ref<LineItem>[];\n}\n"]}
|
|
@@ -13,6 +13,7 @@ exports.Category = void 0;
|
|
|
13
13
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
14
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
|
+
const normalize_field_plugin_1 = require("../plugins/normalize-field.plugin");
|
|
16
17
|
let Category = class Category extends defaultClasses_1.TimeStamps {
|
|
17
18
|
name;
|
|
18
19
|
nameNormalized;
|
|
@@ -61,24 +62,6 @@ exports.Category = Category = __decorate([
|
|
|
61
62
|
deletedAt: null,
|
|
62
63
|
},
|
|
63
64
|
}),
|
|
64
|
-
(0, typegoose_1.
|
|
65
|
-
if (this.name) {
|
|
66
|
-
this.nameNormalized = this.name.toLowerCase();
|
|
67
|
-
}
|
|
68
|
-
next();
|
|
69
|
-
}),
|
|
70
|
-
(0, typegoose_1.pre)('findOneAndUpdate', function (next) {
|
|
71
|
-
const update = this.getUpdate();
|
|
72
|
-
if (update?.name) {
|
|
73
|
-
update.nameNormalized = update.name.toLowerCase();
|
|
74
|
-
}
|
|
75
|
-
if (update?.$set?.name) {
|
|
76
|
-
update.$set.nameNormalized = update.$set.name.toLowerCase();
|
|
77
|
-
}
|
|
78
|
-
if (update?.$setOnInsert?.name) {
|
|
79
|
-
update.$setOnInsert.nameNormalized = update.$setOnInsert.name.toLowerCase();
|
|
80
|
-
}
|
|
81
|
-
next();
|
|
82
|
-
})
|
|
65
|
+
(0, typegoose_1.plugin)(normalize_field_plugin_1.normalizeFieldPlugin, { field: 'name' })
|
|
83
66
|
], Category);
|
|
84
67
|
//# sourceMappingURL=category.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA8E;AAC9E,4EAAqE;AACrE,kDAA2D;AAC3D,8EAAyE;AAelE,IAAM,QAAQ,GAAd,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uBAAuB,EAAE;YACxB,QAAQ,EAAE,EAAE,GAAG,EAAE,CAAC,eAAQ,CAAC,OAAO,EAAE,eAAQ,CAAC,QAAQ,CAAC,EAAE;YACxD,cAAc,EAAE,IAAI;YACpB,SAAS,EAAE,IAAI;SACf;KACD,CACD;IACA,IAAA,kBAAM,EAAC,6CAAoB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;GACnC,QAAQ,CAqBpB","sourcesContent":["import { index, modelOptions, plugin, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ItemType, Status } from '../../../utilities/enum';\nimport { normalizeFieldPlugin } from '../plugins/normalize-field.plugin';\n\n@modelOptions({ schemaOptions: { collection: 'categories' } })\n@index(\n\t{ nameNormalized: 1, itemType: 1 },\n\t{\n\t\tunique: true,\n\t\tpartialFilterExpression: {\n\t\t\titemType: { $in: [ItemType.GROCERY, ItemType.PHARMACY] },\n\t\t\tparentCategory: null,\n\t\t\tdeletedAt: null,\n\t\t},\n\t}\n)\n@plugin(normalizeFieldPlugin, { field: 'name' })\nexport class Category extends TimeStamps {\n\t@prop({ required: true, type: String, trim: true, maxlength: 30 })\n\tpublic name!: string;\n\n\t@prop({ type: String, trim: true, lowercase: true, select: false })\n\tpublic nameNormalized?: string;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ ref: () => Category })\n\tpublic parentCategory?: Ref<Category>;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic note?: string;\n}\n"]}
|
|
@@ -15,7 +15,7 @@ const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
const shop_model_1 = require("./shop.model");
|
|
17
17
|
const _1 = require(".");
|
|
18
|
-
const
|
|
18
|
+
const sorting_order_hooks_1 = require("../utilities/sorting-order.hooks");
|
|
19
19
|
let Dish = class Dish extends defaultClasses_1.TimeStamps {
|
|
20
20
|
shop;
|
|
21
21
|
name;
|
|
@@ -83,7 +83,7 @@ exports.Dish = Dish = __decorate([
|
|
|
83
83
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'dishes' } }),
|
|
84
84
|
(0, typegoose_1.Index)({ shop: 1, deletedAt: 1 }),
|
|
85
85
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
86
|
-
await
|
|
86
|
+
await sorting_order_hooks_1.handlePreSaveForSorting.call(this, _1.DishModel, {
|
|
87
87
|
shop: this.shop,
|
|
88
88
|
});
|
|
89
89
|
next();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dish.model.js","sourceRoot":"/","sources":["libraries/mongo/models/dish.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAAuD;AACvD,6CAAoC;AACpC,wBAA8B;AAC9B,
|
|
1
|
+
{"version":3,"file":"dish.model.js","sourceRoot":"/","sources":["libraries/mongo/models/dish.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAAuD;AACvD,6CAAoC;AACpC,wBAA8B;AAC9B,0EAA2E;AAYpE,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,IAAI,CAAa;IAGjB,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,WAAW,CAAU;IAGrB,QAAQ,CAAgB;IAGxB,WAAW,CAAY;IAGvB,QAAQ,CAAU;IAGlB,GAAG,CAAU;IAGb,MAAM,CAAU;IAGhB,OAAO,CAAU;IAGjB,iBAAiB,CAAY;IAG7B,YAAY,CAAU;CAC7B,CAAA;AApCY,oBAAI;AAET;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,G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AAQ,EAAE,EAAE,CAAC;IACzD,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAChC,IAAA,eAAG,EAAO,MAAM,EAAE,KAAK,WAAW,IAAI;QAEtC,MAAM,6CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,YAAS,EAAE;YACnD,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CAAC;QAEH,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,IAAI,CAoChB","sourcesContent":["import { Index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { DishCategory } from '../../../utilities/enum';\nimport { Shop } from './shop.model';\nimport { DishModel } from '.';\nimport { handlePreSaveForSorting } from '../utilities/sorting-order.hooks';\n\n@modelOptions({ schemaOptions: { collection: 'dishes' } })\n@Index({ shop: 1, deletedAt: 1 })\n@pre<Dish>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, DishModel, {\n\t\tshop: this.shop,\n\t});\n\n\tnext();\n})\nexport class Dish extends TimeStamps {\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ type: String })\n\tpublic description?: string;\n\n\t@prop({ required: true, type: String, enum: DishCategory })\n\tpublic category!: DishCategory;\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic ingredients?: string[];\n\n\t@prop({ required: true, type: Number })\n\tpublic calories!: number;\n\n\t@prop({ required: true, type: Number })\n\tpublic fat!: number;\n\n\t@prop({ required: true, type: Number })\n\tpublic fibers!: number;\n\n\t@prop({ required: true, type: Number })\n\tpublic protein!: number;\n\n\t@prop({ required: true, type: () => [Number] })\n\tpublic portionPercentage!: number[];\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -14,7 +14,7 @@ const typegoose_1 = require("@typegoose/typegoose");
|
|
|
14
14
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
const _1 = require(".");
|
|
17
|
-
const
|
|
17
|
+
const sorting_order_hooks_1 = require("../utilities/sorting-order.hooks");
|
|
18
18
|
let Faq = class Faq extends defaultClasses_1.TimeStamps {
|
|
19
19
|
question;
|
|
20
20
|
answer;
|
|
@@ -46,7 +46,7 @@ __decorate([
|
|
|
46
46
|
exports.Faq = Faq = __decorate([
|
|
47
47
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'faqs' } }),
|
|
48
48
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
49
|
-
await
|
|
49
|
+
await sorting_order_hooks_1.handlePreSaveForSorting.call(this, _1.FaqModel);
|
|
50
50
|
next();
|
|
51
51
|
})
|
|
52
52
|
], Faq);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"faq.model.js","sourceRoot":"/","sources":["libraries/mongo/models/faq.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAiE;AACjE,wBAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"faq.model.js","sourceRoot":"/","sources":["libraries/mongo/models/faq.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAiE;AACjE,wBAA6B;AAC7B,0EAA2E;AASpE,IAAM,GAAG,GAAT,MAAM,GAAI,SAAQ,2BAAU;IAE3B,QAAQ,CAAU;IAGlB,MAAM,CAAU;IAGhB,WAAW,CAAkB;IAG7B,MAAM,CAAU;IAGhB,YAAY,CAAU;CAC7B,CAAA;AAfY,kBAAG;AAER;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;qCACd;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mCAChB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,qBAAc,EAAE,CAAC;;wCACX;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;mCACxB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCACM;cAdjB,GAAG;IAPf,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IACvD,IAAA,eAAG,EAAM,MAAM,EAAE,KAAK,WAAW,IAAI;QAErC,MAAM,6CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,WAAQ,CAAC,CAAC;QAEnD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,GAAG,CAef","sourcesContent":["import { modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { FaqAccountType, Status } from '../../../utilities/enum';\nimport { FaqModel } from '.';\nimport { handlePreSaveForSorting } from '../utilities/sorting-order.hooks';\n\n@modelOptions({ schemaOptions: { collection: 'faqs' } })\n@pre<Faq>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, FaqModel);\n\n\tnext();\n})\nexport class Faq extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic question!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic answer!: string;\n\n\t@prop({ required: true, enum: FaqAccountType })\n\tpublic accountType!: FaqAccountType;\n\n\t@prop({ enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -14,7 +14,7 @@ const typegoose_1 = require("@typegoose/typegoose");
|
|
|
14
14
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
const _1 = require(".");
|
|
17
|
-
const
|
|
17
|
+
const sorting_order_hooks_1 = require("../utilities/sorting-order.hooks");
|
|
18
18
|
let FilterContainer = class FilterContainer extends defaultClasses_1.TimeStamps {
|
|
19
19
|
name;
|
|
20
20
|
deals;
|
|
@@ -52,11 +52,11 @@ exports.FilterContainer = FilterContainer = __decorate([
|
|
|
52
52
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'filterContainers' } }),
|
|
53
53
|
(0, typegoose_1.Index)({ itemType: 1, deletedAt: 1 }),
|
|
54
54
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
55
|
-
await
|
|
55
|
+
await sorting_order_hooks_1.handlePreSaveForSortingWithStatus.call(this, _1.FilterContainerModel, { itemType: this.itemType });
|
|
56
56
|
next();
|
|
57
57
|
}),
|
|
58
58
|
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
59
|
-
await
|
|
59
|
+
await sorting_order_hooks_1.handlePreUpdateForSortingWithStatus.call(this, _1.FilterContainerModel, ['itemType']);
|
|
60
60
|
next();
|
|
61
61
|
})
|
|
62
62
|
], FilterContainer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-container.model.js","sourceRoot":"/","sources":["libraries/mongo/models/filter-container.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,kDAAyE;AACzE,wBAAyC;AAEzC,
|
|
1
|
+
{"version":3,"file":"filter-container.model.js","sourceRoot":"/","sources":["libraries/mongo/models/filter-container.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,kDAAyE;AACzE,wBAAyC;AAEzC,0EAG0C;AAcnC,IAAM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,eAAG,EAAkB,kBAAkB,EAAE,KAAK,WAA8C,IAAI;QAChG,MAAM,yDAAmC,CAAC,IAAI,CAAC,IAAI,EAAE,uBAAoB,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAEzF,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,eAAe,CAkB3B","sourcesContent":["import { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Status, UserAppSectionItemType } from '../../../utilities/enum';\nimport { FilterContainerModel } from '.';\nimport { Query } from 'mongoose';\nimport {\n\thandlePreSaveForSortingWithStatus,\n\thandlePreUpdateForSortingWithStatus,\n} from '../utilities/sorting-order.hooks';\n\n@modelOptions({ schemaOptions: { collection: 'filterContainers' } })\n@Index({ itemType: 1, deletedAt: 1 })\n@pre<FilterContainer>('save', async function (next) {\n\tawait handlePreSaveForSortingWithStatus.call(this, FilterContainerModel, { itemType: this.itemType });\n\n\tnext();\n})\n@pre<FilterContainer>('findOneAndUpdate', async function (this: Query<any, FilterContainer>, next) {\n\tawait handlePreUpdateForSortingWithStatus.call(this, FilterContainerModel, ['itemType']);\n\n\tnext();\n})\nexport class FilterContainer extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: [String] })\n\tpublic deals!: string[]; // e.g., \"5\", \"10\", \"20\", \"30\", \"double_menu\"\n\n\t@prop({ type: String, enum: UserAppSectionItemType })\n\tpublic itemType?: UserAppSectionItemType;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Boolean, default: true })\n\tpublic isVisible!: boolean;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -19,7 +19,7 @@ const enum_1 = require("../../../utilities/enum");
|
|
|
19
19
|
const user_model_1 = require("./user.model");
|
|
20
20
|
const admin_model_1 = require("./admin.model");
|
|
21
21
|
const parent_model_1 = require("./parent.model");
|
|
22
|
-
const
|
|
22
|
+
const unique_id_hooks_1 = require("../utilities/unique-id.hooks");
|
|
23
23
|
const _1 = require(".");
|
|
24
24
|
let FinanceSettlement = class FinanceSettlement extends defaultClasses_1.TimeStamps {
|
|
25
25
|
settlementId;
|
|
@@ -119,7 +119,7 @@ exports.FinanceSettlement = FinanceSettlement = __decorate([
|
|
|
119
119
|
(0, typegoose_1.index)({ settlementType: 1, createdAt: -1 }),
|
|
120
120
|
(0, typegoose_1.index)({ accountType: 1, settlementType: 1, createdAt: -1 }),
|
|
121
121
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
122
|
-
await
|
|
122
|
+
await unique_id_hooks_1.handlePreSaveForUniqueId.call(this, _1.FinanceSettlementModel, 'settlementId', 10);
|
|
123
123
|
next();
|
|
124
124
|
})
|
|
125
125
|
], FinanceSettlement);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"finance-settlement.model.js","sourceRoot":"/","sources":["libraries/mongo/models/finance-settlement.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,+CAAsC;AACtC,6CAAoC;AACpC,+CAAsC;AACtC,kDAAgF;AAChF,6CAAoC;AACpC,+CAAsC;AACtC,iDAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"finance-settlement.model.js","sourceRoot":"/","sources":["libraries/mongo/models/finance-settlement.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,+CAAsC;AACtC,6CAAoC;AACpC,+CAAsC;AACtC,kDAAgF;AAChF,6CAAoC;AACpC,+CAAsC;AACtC,iDAAwC;AACxC,kEAAwE;AACxE,wBAA2C;AAWpC,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,2BAAU;IAEzC,YAAY,CAAS;IAGrB,WAAW,CAAe;IAG1B,KAAK,CAAc;IAGnB,MAAM,CAAe;IAGrB,IAAI,CAAa;IAGj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,WAAW,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IAC3D,IAAA,eAAG,EAAoB,MAAM,EAAE,KAAK,WAAW,IAAI;QAEnD,MAAM,0CAAwB,CAAC,IAAI,CAAC,IAAI,EAAE,yBAAsB,EAAE,cAAc,EAAE,EAAE,CAAC,CAAC;QAEtF,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,iBAAiB,CAsD7B","sourcesContent":["import { index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Order } from './order.model';\nimport { Shop } from './shop.model';\nimport { Rider } from './rider.model';\nimport { AccountType, ItemType, SettlementType } from '../../../utilities/enum';\nimport { User } from './user.model';\nimport { Admin } from './admin.model';\nimport { Parent } from './parent.model';\nimport { handlePreSaveForUniqueId } from '../utilities/unique-id.hooks';\nimport { FinanceSettlementModel } from '.';\n\n@modelOptions({ schemaOptions: { collection: 'financeSettlements' } })\n@index({ settlementType: 1, createdAt: -1 })\n@index({ accountType: 1, settlementType: 1, createdAt: -1 })\n@pre<FinanceSettlement>('save', async function (next) {\n\t// Generate unique id if not exists\n\tawait handlePreSaveForUniqueId.call(this, FinanceSettlementModel, 'settlementId', 10);\n\n\tnext();\n})\nexport class FinanceSettlement extends TimeStamps {\n\t@prop({ type: String, unique: true, index: true })\n\tpublic settlementId: string;\n\n\t@prop({ required: true, type: String, enum: AccountType })\n\tpublic accountType!: AccountType;\n\n\t@prop({ ref: () => Order, index: true })\n\tpublic order?: Ref<Order>;\n\n\t@prop({ ref: () => Parent, index: true })\n\tpublic parent?: Ref<Parent>;\n\n\t@prop({ ref: () => Shop, index: true })\n\tpublic shop?: Ref<Shop>;\n\n\t@prop({ type: String, enum: ItemType, index: true })\n\tpublic itemType?: ItemType;\n\n\t@prop({ ref: () => Rider, index: true })\n\tpublic rider?: Ref<Rider>;\n\n\t@prop({ ref: () => User, index: true })\n\tpublic user?: Ref<User>;\n\n\t@prop({ required: true, type: String, enum: SettlementType })\n\tpublic settlementType!: SettlementType;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic amount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryAmount?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic amountFromItems?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryAmountFromItems?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic amountFromDelivery?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryAmountFromDelivery?: number;\n\n\t@prop({ type: String })\n\tpublic paymentIntentId?: string;\n\n\t@prop({ ref: () => Admin })\n\tpublic settleBy?: Ref<Admin>;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic adminNote?: string;\n}\n"]}
|
|
@@ -16,7 +16,7 @@ const enum_1 = require("../../../utilities/enum");
|
|
|
16
16
|
const shop_model_1 = require("./shop.model");
|
|
17
17
|
const tag_model_1 = require("./tag.model");
|
|
18
18
|
const zone_model_1 = require("./zone.model");
|
|
19
|
-
const
|
|
19
|
+
const sorting_order_hooks_1 = require("../utilities/sorting-order.hooks");
|
|
20
20
|
const _1 = require(".");
|
|
21
21
|
let ListContainer = class ListContainer extends defaultClasses_1.TimeStamps {
|
|
22
22
|
name;
|
|
@@ -81,11 +81,11 @@ exports.ListContainer = ListContainer = __decorate([
|
|
|
81
81
|
(0, typegoose_1.index)({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } }),
|
|
82
82
|
(0, typegoose_1.index)({ itemType: 1, deletedAt: 1 }),
|
|
83
83
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
84
|
-
await
|
|
84
|
+
await sorting_order_hooks_1.handlePreSaveForSortingWithStatus.call(this, _1.ListContainerModel, { itemType: this.itemType });
|
|
85
85
|
next();
|
|
86
86
|
}),
|
|
87
87
|
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
88
|
-
await
|
|
88
|
+
await sorting_order_hooks_1.handlePreUpdateForSortingWithStatus.call(this, _1.ListContainerModel, ['itemType']);
|
|
89
89
|
next();
|
|
90
90
|
})
|
|
91
91
|
], ListContainer);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-container.model.js","sourceRoot":"/","sources":["libraries/mongo/models/list-container.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAA2D;AAC3D,6CAAoC;AACpC,2CAAkC;AAClC,6CAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"list-container.model.js","sourceRoot":"/","sources":["libraries/mongo/models/list-container.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAA2D;AAC3D,6CAAoC;AACpC,2CAAkC;AAClC,6CAAoC;AAEpC,0EAG0C;AAC1C,wBAAuC;AAehC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,2BAAU;IAErC,IAAI,CAAU;IAGd,QAAQ,CAAY;IAGpB,KAAK,CAAU;IAGf,MAAM,CAAU;IAGhB,KAAK,CAAe;IAGpB,KAAK,CAAY;IAGjB,IAAI,CAAc;IAGlB,KAAK,CAAe;IAGpB,MAAM,CAAU;IAGhB,SAAS,CAAW;IAGpB,YAAY,CAAU;CAC7B,CAAA;AAjCY,sCAAa;AAElB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;;2CACjC;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAQ,EAAE,CAAC;;+CAC5B;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACjB;AAGf;IAD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C,IAAA,eAAG,EAAgB,MAAM,EAAE,KAAK,WAAW,IAAI;QAC/C,MAAM,uDAAiC,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAkB,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAEpG,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,eAAG,EAAgB,kBAAkB,EAAE,KAAK,WAA4C,IAAI;QAC5F,MAAM,yDAAmC,CAAC,IAAI,CAAC,IAAI,EAAE,qBAAkB,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;QAEvF,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,aAAa,CAiCzB","sourcesContent":["import { index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ItemType, Status } from '../../../utilities/enum';\nimport { Shop } from './shop.model';\nimport { Tag } from './tag.model';\nimport { Zone } from './zone.model';\nimport { Query } from 'mongoose';\nimport {\n\thandlePreSaveForSortingWithStatus,\n\thandlePreUpdateForSortingWithStatus,\n} from '../utilities/sorting-order.hooks';\nimport { ListContainerModel } from '.';\n\n@modelOptions({ schemaOptions: { collection: 'listContainers' } })\n@index({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@index({ itemType: 1, deletedAt: 1 })\n@pre<ListContainer>('save', async function (next) {\n\tawait handlePreSaveForSortingWithStatus.call(this, ListContainerModel, { itemType: this.itemType });\n\n\tnext();\n})\n@pre<ListContainer>('findOneAndUpdate', async function (this: Query<any, ListContainer>, next) {\n\tawait handlePreUpdateForSortingWithStatus.call(this, ListContainerModel, ['itemType']);\n\n\tnext();\n})\nexport class ListContainer extends TimeStamps {\n\t@prop({ required: true, type: String, maxlength: 30 })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ required: true, type: String })\n\tpublic image!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic banner!: string;\n\n\t@prop({ ref: () => Zone, default: [] })\n\tpublic zones?: Ref<Zone>[];\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic deals?: string[];\n\n\t@prop({ ref: () => Tag, default: [] })\n\tpublic tags?: Ref<Tag>[];\n\n\t@prop({ ref: () => Shop, default: [] })\n\tpublic shops?: Ref<Shop>[];\n\n\t@prop({ enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Boolean, default: true })\n\tpublic isVisible!: boolean;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|