@lyxa.ai/core 1.0.101 → 1.0.103
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/index.js.map +1 -1
- package/dist/libraries/auth/index.js.map +1 -1
- package/dist/libraries/auth/refreshtoken.js.map +1 -1
- package/dist/libraries/auth/repository.js.map +1 -1
- package/dist/libraries/cache/settings/index.js.map +1 -1
- package/dist/libraries/configuration/index.js.map +1 -1
- package/dist/libraries/configuration/types/EnvironmentConfigurationType.js.map +1 -1
- package/dist/libraries/dispatcher/index.js.map +1 -1
- package/dist/libraries/event/BaseEvent.js.map +1 -1
- package/dist/libraries/event/decorators/metadata.js.map +1 -1
- package/dist/libraries/event/decorators/subscribe.js.map +1 -1
- package/dist/libraries/event/index.js.map +1 -1
- package/dist/libraries/event/registry/SubscriptionRegistry.js.map +1 -1
- package/dist/libraries/event/test/OrderCreationEvent.js.map +1 -1
- package/dist/libraries/firebase/fcmService.js.map +1 -1
- package/dist/libraries/firebase/index.js.map +1 -1
- package/dist/libraries/index.js.map +1 -1
- package/dist/libraries/logger/index.js.map +1 -1
- package/dist/libraries/map/index.js.map +1 -1
- package/dist/libraries/map/interfaces/IMapService.js.map +1 -1
- package/dist/libraries/map/mapService.js.map +1 -1
- package/dist/libraries/map/providers/google-maps.js.map +1 -1
- package/dist/libraries/map/providers/index.js.map +1 -1
- package/dist/libraries/mongo/index.js.map +1 -1
- package/dist/libraries/mongo/models/activity-log.model.js.map +1 -1
- package/dist/libraries/mongo/models/admin-access-control.model.js.map +1 -1
- package/dist/libraries/mongo/models/admin.model.js.map +1 -1
- package/dist/libraries/mongo/models/agent-performance.model.d.ts +13 -0
- package/dist/libraries/mongo/models/agent-performance.model.js +68 -0
- package/dist/libraries/mongo/models/agent-performance.model.js.map +1 -0
- package/dist/libraries/mongo/models/app-screen-setting.model.d.ts +9 -0
- package/dist/libraries/mongo/models/app-screen-setting.model.js +47 -0
- package/dist/libraries/mongo/models/app-screen-setting.model.js.map +1 -0
- package/dist/libraries/mongo/models/attribute.model.js.map +1 -1
- package/dist/libraries/mongo/models/banner.model.js.map +1 -1
- package/dist/libraries/mongo/models/base/base-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/base/base-review.model.js.map +1 -1
- package/dist/libraries/mongo/models/bob-finance.model.js.map +1 -1
- package/dist/libraries/mongo/models/brand.model.js.map +1 -1
- package/dist/libraries/mongo/models/cancellation-reason.model.js.map +1 -1
- package/dist/libraries/mongo/models/card.model.js.map +1 -1
- package/dist/libraries/mongo/models/cart-participant.model.js.map +1 -1
- package/dist/libraries/mongo/models/cart.model.js.map +1 -1
- package/dist/libraries/mongo/models/category.model.js.map +1 -1
- package/dist/libraries/mongo/models/chat-room.model.d.ts +16 -0
- package/dist/libraries/mongo/models/chat-room.model.js +79 -0
- package/dist/libraries/mongo/models/chat-room.model.js.map +1 -0
- package/dist/libraries/mongo/models/core-auth-identity.model.js.map +1 -1
- package/dist/libraries/mongo/models/core-user.model.js.map +1 -1
- package/dist/libraries/mongo/models/counter.model.js.map +1 -1
- package/dist/libraries/mongo/models/coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/deal-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/default-chat.model.js.map +1 -1
- package/dist/libraries/mongo/models/dish.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/attribute-item.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/attribute-map.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/business-development-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/cash-settlement.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/charge-setting.model.d.ts +14 -0
- package/dist/libraries/mongo/models/embedded/charge-setting.model.js +60 -0
- package/dist/libraries/mongo/models/embedded/charge-setting.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/charge-settings.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/charge.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/chat-participant.model.d.ts +13 -0
- package/dist/libraries/mongo/models/embedded/chat-participant.model.js +47 -0
- package/dist/libraries/mongo/models/embedded/chat-participant.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/courier-order-finance.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/courier-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/currency-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/currency.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/customer-support-batches.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/customer-support-numbers.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/delivery-charge-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/delivery-info.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/featured-item.mode.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/line-item-attribute.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/marketing-cut.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/order-cancel.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/order-finance.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/order-pricing.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/order-refund.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/otp-fields.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/package.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/parent-document.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/payment-attempt.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/payment-infromation.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/payout-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/plus-settings.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/price-breakdown.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/product-nutrition.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/profit.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/referral-discount-config.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/regular-order-finance.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/rider-assignment-model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/rider-batches.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/rider-equipment.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/rider-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/service-fee-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/shop-document.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/status-timeline.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/subscription-summary.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/support-reason-info.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/ticket-message.model.d.ts +11 -0
- package/dist/libraries/mongo/models/{providers/courier-order-finance.model.js → embedded/ticket-message.model.js} +23 -11
- package/dist/libraries/mongo/models/embedded/ticket-message.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/trip-leg.mode.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/vat.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/zone-geometry.mode.js.map +1 -1
- package/dist/libraries/mongo/models/faq.model.js.map +1 -1
- package/dist/libraries/mongo/models/favourite.model.js.map +1 -1
- package/dist/libraries/mongo/models/featured-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/filter-container.model.js.map +1 -1
- package/dist/libraries/mongo/models/finance-settlement.model.js.map +1 -1
- package/dist/libraries/mongo/models/gallery.model.js.map +1 -1
- package/dist/libraries/mongo/models/index.d.ts +13 -0
- package/dist/libraries/mongo/models/index.js +14 -1
- package/dist/libraries/mongo/models/index.js.map +1 -1
- package/dist/libraries/mongo/models/line-item.model.js.map +1 -1
- package/dist/libraries/mongo/models/list-container.model.js.map +1 -1
- package/dist/libraries/mongo/models/loyalty-point-category.model.js.map +1 -1
- package/dist/libraries/mongo/models/loyalty-point-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/loyalty-point.model.js.map +1 -1
- package/dist/libraries/mongo/models/marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/meal-plan.model.js.map +1 -1
- package/dist/libraries/mongo/models/message.model.d.ts +18 -0
- package/dist/libraries/mongo/models/message.model.js +70 -0
- package/dist/libraries/mongo/models/message.model.js.map +1 -0
- package/dist/libraries/mongo/models/notification.model.js.map +1 -1
- package/dist/libraries/mongo/models/nutrition.model.js.map +1 -1
- package/dist/libraries/mongo/models/order-delivery.model.js.map +1 -1
- package/dist/libraries/mongo/models/order-payment.model.d.ts +21 -0
- package/dist/libraries/mongo/models/order-payment.model.js +96 -0
- package/dist/libraries/mongo/models/order-payment.model.js.map +1 -0
- package/dist/libraries/mongo/models/order.model.js.map +1 -1
- package/dist/libraries/mongo/models/parent.model.js.map +1 -1
- package/dist/libraries/mongo/models/payout.model.js.map +1 -1
- package/dist/libraries/mongo/models/product-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/product.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/areeba-card.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/buy1-get1-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/core-apple-auth-identity.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/core-email-auth-identity.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/core-google-auth-identity.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/core-phone-auth-identity.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/courier-order.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/custom-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/discount-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/featured-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/free-delivery-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/global-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/individual-store-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/individual-user-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/loyalty-point-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/punch-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/referral-code-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/referral-reward-coupon.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/regular-order.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/rider-payout.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/shop-payout.model.js.map +1 -1
- package/dist/libraries/mongo/models/punch-marketing-history.model.js.map +1 -1
- package/dist/libraries/mongo/models/rating-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/referral-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/request-area.model.js.map +1 -1
- package/dist/libraries/mongo/models/reward.model.js.map +1 -1
- package/dist/libraries/mongo/models/rider-review.model.js.map +1 -1
- package/dist/libraries/mongo/models/rider-timeout.model.js.map +1 -1
- package/dist/libraries/mongo/models/rider-tracking.model.js.map +1 -1
- package/dist/libraries/mongo/models/rider.model.js.map +1 -1
- package/dist/libraries/mongo/models/role.model.js.map +1 -1
- package/dist/libraries/mongo/models/setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/shared/address.model.js.map +1 -1
- package/dist/libraries/mongo/models/shared/duration.model.js.map +1 -1
- package/dist/libraries/mongo/models/shared/geo-location.model.js.map +1 -1
- package/dist/libraries/mongo/models/shared/work-hour.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop-access-control.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop-category.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop-meal-plan.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop-review.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop.model.js.map +1 -1
- package/dist/libraries/mongo/models/subscription-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/subscription.model.js.map +1 -1
- package/dist/libraries/mongo/models/support-reason.model.js.map +1 -1
- package/dist/libraries/mongo/models/tag.model.js.map +1 -1
- package/dist/libraries/mongo/models/terms-and-conditions.model.js.map +1 -1
- package/dist/libraries/mongo/models/ticket.model.d.ts +29 -0
- package/dist/libraries/mongo/models/ticket.model.js +178 -0
- package/dist/libraries/mongo/models/ticket.model.js.map +1 -0
- package/dist/libraries/mongo/models/transaction.model.js.map +1 -1
- package/dist/libraries/mongo/models/user-app-section-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/user.model.js.map +1 -1
- package/dist/libraries/mongo/models/zone.model.js.map +1 -1
- package/dist/libraries/mongo/plugins/soft-delete-plugin.js.map +1 -1
- package/dist/libraries/redis/index.js.map +1 -1
- package/dist/libraries/secrets/index.js.map +1 -1
- package/dist/libraries/trpc/context.js.map +1 -1
- package/dist/libraries/trpc/index.js.map +1 -1
- package/dist/libraries/trpc/middlewares/auth.d.ts +3 -3
- package/dist/libraries/trpc/middlewares/auth.js.map +1 -1
- package/dist/libraries/trpc/middlewares/cors.js.map +1 -1
- package/dist/libraries/trpc/middlewares/phone-verified.d.ts +3 -3
- package/dist/libraries/trpc/middlewares/phone-verified.js.map +1 -1
- package/dist/libraries/trpc/middlewares/publicUserDecoder.d.ts +3 -3
- package/dist/libraries/trpc/middlewares/publicUserDecoder.js.map +1 -1
- package/dist/libraries/twilio/index.js.map +1 -1
- package/dist/libraries/upload/index.js.map +1 -1
- package/dist/utilities/common/password.js.map +1 -1
- package/dist/utilities/common/week.js.map +1 -1
- package/dist/utilities/currency.js.map +1 -1
- package/dist/utilities/enum.d.ts +22 -1
- package/dist/utilities/enum.js +26 -1
- package/dist/utilities/enum.js.map +1 -1
- package/dist/utilities/error-handler.js.map +1 -1
- package/dist/utilities/error-middleware.js.map +1 -1
- package/dist/utilities/pagination.d.ts +5 -5
- package/dist/utilities/pagination.js.map +1 -1
- package/dist/utilities/response.js.map +1 -1
- package/dist/utilities/search.js.map +1 -1
- package/dist/utilities/sorting.js.map +1 -1
- package/dist/utilities/transformers.js.map +1 -1
- package/dist/utilities/validation/common-validation.d.ts +118 -118
- package/dist/utilities/validation/common-validation.js.map +1 -1
- package/dist/utilities/validation/global-validation.js.map +1 -1
- package/dist/utilities/validation/index.js.map +1 -1
- package/package.json +54 -54
- package/dist/libraries/mongo/models/embedded/loyaltyPoint.model.d.ts +0 -16
- package/dist/libraries/mongo/models/embedded/loyaltyPoint.model.js +0 -61
- package/dist/libraries/mongo/models/embedded/loyaltyPoint.model.js.map +0 -1
- package/dist/libraries/mongo/models/order-finance.model.d.ts +0 -22
- package/dist/libraries/mongo/models/order-finance.model.js +0 -83
- package/dist/libraries/mongo/models/order-finance.model.js.map +0 -1
- package/dist/libraries/mongo/models/providers/courier-order-finance.model.d.ts +0 -7
- package/dist/libraries/mongo/models/providers/courier-order-finance.model.js.map +0 -1
- package/dist/libraries/mongo/models/providers/regular-order-finance.model.d.ts +0 -25
- package/dist/libraries/mongo/models/providers/regular-order-finance.model.js +0 -95
- package/dist/libraries/mongo/models/providers/regular-order-finance.model.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shop-category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/shop-category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAAiD;AACjD,qDAA4C;AAC5C,6CAAoC;AACpC,wBAAsC;AAiC/B,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,2BAAU;IAEpC,IAAI,CAAa;IAGjB,QAAQ,CAAiB;IAGzB,MAAM,CAAU;IAGhB,IAAI,CAAU;IAGd,YAAY,CAAU;CAC7B,CAAA;AAfY,oCAAY;AAEjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;0CAClB;AAGjB;IADN,I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;iBACD,CAAC,CAAC,IAAI,EAAE,CAAC;gBAGV,IAAI,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACrE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,KAAc,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,YAAY,CAexB","sourcesContent":["import { Index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Status } from '../../../utilities/enum';\nimport { Category } from './category.model';\nimport { Shop } from './shop.model';\nimport { ShopCategoryModel } from '.';\n\n@modelOptions({ schemaOptions: { collection: 'shopCategories' } })\n@Index({ shop: 1, category: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@Index({ shop: 1, deletedAt: 1 })\n@pre<ShopCategory>('save', async function (next) {\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\n\t\ttry {\n\t\t\t// Find the maximum sortingOrder for products with the same shop that aren't deleted\n\t\t\tconst maxSortingOrder = await ShopCategoryModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\tshop: this.shop,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t} catch (error) {\n\t\t\treturn next(error as Error);\n\t\t}\n\t}\n\tnext();\n})\nexport class ShopCategory extends TimeStamps {\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ required: true, ref: () => Category })\n\tpublic category!: Ref<Category>;\n\n\t@prop({ required: true, 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\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shop-category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/shop-category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAAiD;AACjD,qDAA4C;AAC5C,6CAAoC;AACpC,wBAAsC;AAiC/B,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,2BAAU;IAEpC,IAAI,CAAa;IAGjB,QAAQ,CAAiB;IAGzB,MAAM,CAAU;IAGhB,IAAI,CAAU;IAGd,YAAY,CAAU;CAC7B,CAAA;AAfY,oCAAY;AAEjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;0CAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,yBAAQ,EAAE,CAAC;;8CACd;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;4CACtD;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;0CAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDACM;uBAdjB,YAAY;IA/BxB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE,CAAC;IACjE,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAC/F,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAChC,IAAA,eAAG,EAAe,MAAM,EAAE,KAAK,WAAW,IAAI;QAE9C,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,WAAW,EAAE,CAAC;YAC5D,IAAI,CAAC;gBAEJ,MAAM,eAAe,GAAG,MAAM,oBAAiB,CAAC,SAAS,CAA8B;oBACtF;wBACC,MAAM,EAAE;4BACP,IAAI,EAAE,IAAI,CAAC,IAAI;4BACf,SAAS,EAAE,IAAI;yBACf;qBACD;oBACD;wBACC,MAAM,EAAE;4BACP,GAAG,EAAE,IAAI;4BACT,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;yBAC1C;qBACD;iBACD,CAAC,CAAC,IAAI,EAAE,CAAC;gBAGV,IAAI,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACrE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,KAAc,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,YAAY,CAexB","sourcesContent":["import { Index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { Status } from '../../../utilities/enum';\r\nimport { Category } from './category.model';\r\nimport { Shop } from './shop.model';\r\nimport { ShopCategoryModel } from '.';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'shopCategories' } })\r\n@Index({ shop: 1, category: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\r\n@Index({ shop: 1, deletedAt: 1 })\r\n@pre<ShopCategory>('save', async function (next) {\r\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\r\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\r\n\t\ttry {\r\n\t\t\t// Find the maximum sortingOrder for products with the same shop that aren't deleted\r\n\t\t\tconst maxSortingOrder = await ShopCategoryModel.aggregate<{ maxSortingOrder: number }>([\r\n\t\t\t\t{\r\n\t\t\t\t\t$match: {\r\n\t\t\t\t\t\tshop: this.shop,\r\n\t\t\t\t\t\tdeletedAt: null,\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t$group: {\r\n\t\t\t\t\t\t_id: null,\r\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t]).exec();\r\n\r\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\r\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\r\n\t\t} catch (error) {\r\n\t\t\treturn next(error as Error);\r\n\t\t}\r\n\t}\r\n\tnext();\r\n})\r\nexport class ShopCategory extends TimeStamps {\r\n\t@prop({ required: true, ref: () => Shop })\r\n\tpublic shop!: Ref<Shop>;\r\n\r\n\t@prop({ required: true, ref: () => Category })\r\n\tpublic category!: Ref<Category>;\r\n\r\n\t@prop({ required: true, type: String, enum: Status, default: Status.ACTIVE })\r\n\tpublic status!: Status;\r\n\r\n\t@prop({ type: String, maxlength: 250 })\r\n\tpublic note?: string;\r\n\r\n\t@prop({ type: Number })\r\n\tpublic sortingOrder?: number;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shop-meal-plan.model.js","sourceRoot":"/","sources":["libraries/mongo/models/shop-meal-plan.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,6CAAoC;AACpC,4DAAmD;AACnD,uDAA6C;AAC7C,6CAAoC;AAG7B,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,2BAAU;IAEpC,QAAQ,CAAiB;IAGzB,IAAI,CAAa;IAGjB,MAAM,CAAe;IAGrB,QAAQ,CAAa;CAC5B,CAAA;AAZY,oCAAY;AAEjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,0BAAQ,EAAE,CAAC;;8CACd;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;0CAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;4CACX;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,uBAAO,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;8CACjB;uBAXhB,YAAY;IADxB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,CAAC;GACpD,YAAY,CAYxB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Dish } from './dish.model';\nimport { Package } from './embedded/package.model';\nimport { MealPlan } from './meal-plan.model';\nimport { Shop } from './shop.model';\n\n@modelOptions({ schemaOptions: { collection: 'shopMealPlans' } })\nexport class ShopMealPlan extends TimeStamps {\n\t@prop({ required: true, ref: () => MealPlan })\n\tpublic mealPlan!: Ref<MealPlan>;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ ref: () => Dish, default: [] })\n\tpublic dishes?: Ref<Dish>[];\n\n\t@prop({ type: () => [Package], default: [] })\n\tpublic packages?: Package[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shop-meal-plan.model.js","sourceRoot":"/","sources":["libraries/mongo/models/shop-meal-plan.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,6CAAoC;AACpC,4DAAmD;AACnD,uDAA6C;AAC7C,6CAAoC;AAG7B,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,2BAAU;IAEpC,QAAQ,CAAiB;IAGzB,IAAI,CAAa;IAGjB,MAAM,CAAe;IAGrB,QAAQ,CAAa;CAC5B,CAAA;AAZY,oCAAY;AAEjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,0BAAQ,EAAE,CAAC;;8CACd;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;0CAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;4CACX;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,uBAAO,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;8CACjB;uBAXhB,YAAY;IADxB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,CAAC;GACpD,YAAY,CAYxB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { Dish } from './dish.model';\r\nimport { Package } from './embedded/package.model';\r\nimport { MealPlan } from './meal-plan.model';\r\nimport { Shop } from './shop.model';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'shopMealPlans' } })\r\nexport class ShopMealPlan extends TimeStamps {\r\n\t@prop({ required: true, ref: () => MealPlan })\r\n\tpublic mealPlan!: Ref<MealPlan>;\r\n\r\n\t@prop({ required: true, ref: () => Shop })\r\n\tpublic shop!: Ref<Shop>;\r\n\r\n\t@prop({ ref: () => Dish, default: [] })\r\n\tpublic dishes?: Ref<Dish>[];\r\n\r\n\t@prop({ type: () => [Package], default: [] })\r\n\tpublic packages?: Package[];\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shop-review.model.js","sourceRoot":"/","sources":["libraries/mongo/models/shop-review.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,gEAAsD;AACtD,6CAAoC;AAI7B,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,8BAAU;IAElC,IAAI,CAAa;CACxB,CAAA;AAHY,gCAAU;AAEf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;wCAClB;qBAFZ,UAAU;IAFtB,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAClB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,CAAC;GAClD,UAAU,CAGtB","sourcesContent":["import { modelOptions, prop, Ref, Index } from '@typegoose/typegoose';\nimport { BaseReview } from './base/base-review.model';\nimport { Shop } from './shop.model';\n\n@Index({ shop: 1 })\n@modelOptions({ schemaOptions: { collection: 'shopReviews' } })\nexport class ShopReview extends BaseReview {\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shop-review.model.js","sourceRoot":"/","sources":["libraries/mongo/models/shop-review.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,gEAAsD;AACtD,6CAAoC;AAI7B,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,8BAAU;IAElC,IAAI,CAAa;CACxB,CAAA;AAHY,gCAAU;AAEf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;wCAClB;qBAFZ,UAAU;IAFtB,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAClB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,CAAC;GAClD,UAAU,CAGtB","sourcesContent":["import { modelOptions, prop, Ref, Index } from '@typegoose/typegoose';\r\nimport { BaseReview } from './base/base-review.model';\r\nimport { Shop } from './shop.model';\r\n\r\n@Index({ shop: 1 })\r\n@modelOptions({ schemaOptions: { collection: 'shopReviews' } })\r\nexport class ShopReview extends BaseReview {\r\n\t@prop({ required: true, ref: () => Shop })\r\n\tpublic shop!: Ref<Shop>;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shop.model.js","sourceRoot":"/","sources":["libraries/mongo/models/shop.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAqF;AACrF,4EAAqE;AACrE,kDAA6E;AAC7E,+CAAsC;AACtC,wEAA8D;AAC9D,iDAAwC;AACxC,0DAAiD;AACjD,8DAAyE;AACzE,2CAAkC;AAClC,6CAAoC;AACpC,wEAA8D;AAC9D,wBAA8B;AAC9B,sDAA8B;AAmDvB,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,IA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imeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ItemType, ShopOnlineStatus, Status } from '../../../utilities/enum';\nimport { Brand } from './brand.model';\nimport { ShopDocument } from './embedded/shop-document.model';\nimport { Parent } from './parent.model';\nimport { Address } from './shared/address.model';\nimport { StartEndTime, WorkHourSetting } from './shared/work-hour.model';\nimport { Tag } from './tag.model';\nimport { Zone } from './zone.model';\nimport { DeliveryInfo } from './embedded/delivery-info.model';\nimport { ShopModel } from '.';\nimport slugify from 'slugify';\n\n@modelOptions({\n\tschemaOptions: { collection: 'shops' },\n\toptions: { allowMixed: Severity.ALLOW },\n})\n@Index({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@Index({ parent: 1, status: 1, isVisibleToUser: 1, deletedAt: 1 })\n@pre<Shop>('save', async function (next) {\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\n\t\ttry {\n\t\t\t// Find the maximum sortingOrder for shops with the same itemType that aren't deleted\n\t\t\tconst maxSortingOrder = await ShopModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\titemType: this.itemType,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t} catch (error) {\n\t\t\treturn next(error as Error);\n\t\t}\n\t}\n\ttry {\n\t\tif (this.isNew) {\n\t\t\tconst baseSlug = slugify(this.name, { lower: true, strict: true });\n\t\t\tlet slug = baseSlug;\n\t\t\tlet count = 0;\n\t\t\twhile (await ShopModel.exists({ slug })) {\n\t\t\t\tcount++;\n\t\t\t\tslug = `${baseSlug}-${count}`;\n\t\t\t}\n\t\t\tthis.slug = slug;\n\t\t}\n\t\tnext();\n\t} catch (error) {\n\t\tnext(error as Error);\n\t}\n\tnext();\n})\nexport class Shop extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic ownerName!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic email!: string;\n\n\t@prop({ unique: true, type: String })\n\tpublic slug?: string;\n\n\t@prop({ required: true, ref: () => Parent })\n\tpublic parent: Ref<Parent>;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ required: true, type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status!: Status;\n\n\t@prop({ required: true, ref: () => Brand })\n\tpublic brand: Ref<Brand>;\n\n\t@prop({ type: Number, default: 1, min: 1, max: 4 })\n\tpublic priceRange?: number;\n\n\t@prop({ required: true, type: String })\n\tpublic phoneNumber!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic userPhoneNumber!: string;\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic additionalPhoneNumbers?: string[];\n\n\t@prop({ required: true, type: Address })\n\tpublic address!: Address;\n\n\t@prop({ required: true, ref: () => Zone })\n\tpublic zone!: Ref<Zone>;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: String })\n\tpublic banner?: string;\n\n\t@prop({ type: ShopDocument })\n\tpublic document?: ShopDocument;\n\n\t@prop({\n\t\ttype: String,\n\t\tenum: ShopOnlineStatus,\n\t\tdefault: ShopOnlineStatus.OFFLINE,\n\t})\n\tpublic onlineStatus?: ShopOnlineStatus;\n\n\t@prop({ type: WorkHourSetting })\n\tpublic workHourSetting?: WorkHourSetting;\n\n\t@prop({ type: () => [String], default: [] })\n\tpublic dietaries?: string[];\n\n\t@prop({ ref: () => Tag, default: [] })\n\tpublic tags?: Ref<Tag>[];\n\n\t@prop({ required: true, type: Boolean })\n\tpublic isBeirutAuthentic!: boolean;\n\n\t@prop({ required: true, type: Boolean })\n\tpublic isVisibleToUser!: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isShopDelivery?: boolean;\n\n\t@prop({ type: Number })\n\tpublic deliveryFee?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic minimumOrderAmount?: number;\n\n\t@prop({ type: Number, default: Infinity })\n\tpublic orderCapacity?: number;\n\n\t@prop({ type: () => [StartEndTime], default: [] })\n\tpublic shopActiveTimingsOfCurrentDate?: StartEndTime[];\n\n\t@prop({ type: DeliveryInfo })\n\tpublic deliveryInfo?: DeliveryInfo;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n\n\t// Setting\n\t@prop({ type: Boolean, default: false })\n\tpublic allowSpecialInstructions?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isRiderNoteVisible?: boolean;\n\n\t@prop({ type: String })\n\tpublic riderNote?: string;\n\n\t@prop({ type: Number, default: 10 })\n\tpublic defaultPreparationTime?: number;\n\n\t@prop({ type: Number, default: null })\n\texchangeRate?: number;\n\n\t@prop({ required: false, type: () => Boolean })\n\tpublic isFavouriteCategoryVisible?: boolean;\n\n\t@prop({ required: false, type: () => String })\n\tpublic favouriteCategoryTitle?: string;\n\n\t@prop({ required: false, type: () => Boolean })\n\tpublic isBestSellerCategoryVisible?: boolean;\n\n\t@prop({ required: false, type: () => String })\n\tpublic bestSellerCategoryTitle?: string;\n\n\t@prop({ required: true, type: () => Boolean })\n\tpublic orderCapacityEnabled!: boolean\n\n\t@prop({ default: 0, type: () => Number})\n\tpublic avgRating?: number;\n\n\t@prop({default: 0,type: ()=> Number})\n\tpublic ordersCount?: number\n\n\t@prop({default: 0,type: ()=> Number})\n\tpublic customersCount?: number\n}\n"]}
|
|
1
|
+
{"version":3,"file":"shop.model.js","sourceRoot":"/","sources":["libraries/mongo/models/shop.model.ts"],"names":[],"m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,CAAC,IAAI,GAAG,IAAI,CAAC;YAClB,CAAC;YACD,IAAI,EAAE,CAAC;QACR,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAc,CAAC,CAAC;QACtB,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,IAAI,CAsIhB","sourcesContent":["import { modelOptions, prop, Ref, Severity, Index, pre } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { ItemType, ShopOnlineStatus, Status } from '../../../utilities/enum';\r\nimport { Brand } from './brand.model';\r\nimport { ShopDocument } from './embedded/shop-document.model';\r\nimport { Parent } from './parent.model';\r\nimport { Address } from './shared/address.model';\r\nimport { StartEndTime, WorkHourSetting } from './shared/work-hour.model';\r\nimport { Tag } from './tag.model';\r\nimport { Zone } from './zone.model';\r\nimport { DeliveryInfo } from './embedded/delivery-info.model';\r\nimport { ShopModel } from '.';\r\nimport slugify from 'slugify';\r\n\r\n@modelOptions({\r\n\tschemaOptions: { collection: 'shops' },\r\n\toptions: { allowMixed: Severity.ALLOW },\r\n})\r\n@Index({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\r\n@Index({ parent: 1, status: 1, isVisibleToUser: 1, deletedAt: 1 })\r\n@pre<Shop>('save', async function (next) {\r\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\r\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\r\n\t\ttry {\r\n\t\t\t// Find the maximum sortingOrder for shops with the same itemType that aren't deleted\r\n\t\t\tconst maxSortingOrder = await ShopModel.aggregate<{ maxSortingOrder: number }>([\r\n\t\t\t\t{\r\n\t\t\t\t\t$match: {\r\n\t\t\t\t\t\titemType: this.itemType,\r\n\t\t\t\t\t\tdeletedAt: null,\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t$group: {\r\n\t\t\t\t\t\t_id: null,\r\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t]).exec();\r\n\r\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\r\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\r\n\t\t} catch (error) {\r\n\t\t\treturn next(error as Error);\r\n\t\t}\r\n\t}\r\n\ttry {\r\n\t\tif (this.isNew) {\r\n\t\t\tconst baseSlug = slugify(this.name, { lower: true, strict: true });\r\n\t\t\tlet slug = baseSlug;\r\n\t\t\tlet count = 0;\r\n\t\t\twhile (await ShopModel.exists({ slug })) {\r\n\t\t\t\tcount++;\r\n\t\t\t\tslug = `${baseSlug}-${count}`;\r\n\t\t\t}\r\n\t\t\tthis.slug = slug;\r\n\t\t}\r\n\t\tnext();\r\n\t} catch (error) {\r\n\t\tnext(error as Error);\r\n\t}\r\n\tnext();\r\n})\r\nexport class Shop extends TimeStamps {\r\n\t@prop({ required: true, type: String })\r\n\tpublic name!: string;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic ownerName!: string;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic email!: string;\r\n\r\n\t@prop({ unique: true, type: String })\r\n\tpublic slug?: string;\r\n\r\n\t@prop({ required: true, ref: () => Parent })\r\n\tpublic parent: Ref<Parent>;\r\n\r\n\t@prop({ required: true, type: String, enum: ItemType })\r\n\tpublic itemType!: ItemType;\r\n\r\n\t@prop({ required: true, type: String, enum: Status, default: Status.ACTIVE })\r\n\tpublic status!: Status;\r\n\r\n\t@prop({ required: true, ref: () => Brand })\r\n\tpublic brand: Ref<Brand>;\r\n\r\n\t@prop({ type: Number, default: 1, min: 1, max: 4 })\r\n\tpublic priceRange?: number;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic phoneNumber!: string;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic userPhoneNumber!: string;\r\n\r\n\t@prop({ type: () => [String], default: [] })\r\n\tpublic additionalPhoneNumbers?: string[];\r\n\r\n\t@prop({ required: true, type: Address })\r\n\tpublic address!: Address;\r\n\r\n\t@prop({ required: true, ref: () => Zone })\r\n\tpublic zone!: Ref<Zone>;\r\n\r\n\t@prop({ type: String })\r\n\tpublic logo?: string;\r\n\r\n\t@prop({ type: String })\r\n\tpublic banner?: string;\r\n\r\n\t@prop({ type: ShopDocument })\r\n\tpublic document?: ShopDocument;\r\n\r\n\t@prop({\r\n\t\ttype: String,\r\n\t\tenum: ShopOnlineStatus,\r\n\t\tdefault: ShopOnlineStatus.OFFLINE,\r\n\t})\r\n\tpublic onlineStatus?: ShopOnlineStatus;\r\n\r\n\t@prop({ type: WorkHourSetting })\r\n\tpublic workHourSetting?: WorkHourSetting;\r\n\r\n\t@prop({ type: () => [String], default: [] })\r\n\tpublic dietaries?: string[];\r\n\r\n\t@prop({ ref: () => Tag, default: [] })\r\n\tpublic tags?: Ref<Tag>[];\r\n\r\n\t@prop({ required: true, type: Boolean })\r\n\tpublic isBeirutAuthentic!: boolean;\r\n\r\n\t@prop({ required: true, type: Boolean })\r\n\tpublic isVisibleToUser!: boolean;\r\n\r\n\t@prop({ type: Boolean, default: false })\r\n\tpublic isShopDelivery?: boolean;\r\n\r\n\t@prop({ type: Number })\r\n\tpublic deliveryFee?: number;\r\n\r\n\t@prop({ type: Number, default: 0 })\r\n\tpublic minimumOrderAmount?: number;\r\n\r\n\t@prop({ type: Number, default: Infinity })\r\n\tpublic orderCapacity?: number;\r\n\r\n\t@prop({ type: () => [StartEndTime], default: [] })\r\n\tpublic shopActiveTimingsOfCurrentDate?: StartEndTime[];\r\n\r\n\t@prop({ type: DeliveryInfo })\r\n\tpublic deliveryInfo?: DeliveryInfo;\r\n\r\n\t@prop({ type: Number })\r\n\tpublic sortingOrder?: number;\r\n\r\n\t// Setting\r\n\t@prop({ type: Boolean, default: false })\r\n\tpublic allowSpecialInstructions?: boolean;\r\n\r\n\t@prop({ type: Boolean, default: false })\r\n\tpublic isRiderNoteVisible?: boolean;\r\n\r\n\t@prop({ type: String })\r\n\tpublic riderNote?: string;\r\n\r\n\t@prop({ type: Number, default: 10 })\r\n\tpublic defaultPreparationTime?: number;\r\n\r\n\t@prop({ type: Number, default: null })\r\n\texchangeRate?: number;\r\n\r\n\t@prop({ required: false, type: () => Boolean })\r\n\tpublic isFavouriteCategoryVisible?: boolean;\r\n\r\n\t@prop({ required: false, type: () => String })\r\n\tpublic favouriteCategoryTitle?: string;\r\n\r\n\t@prop({ required: false, type: () => Boolean })\r\n\tpublic isBestSellerCategoryVisible?: boolean;\r\n\r\n\t@prop({ required: false, type: () => String })\r\n\tpublic bestSellerCategoryTitle?: string;\r\n\r\n\t@prop({ required: true, type: () => Boolean })\r\n\tpublic orderCapacityEnabled!: boolean\r\n\r\n\t@prop({ default: 0, type: () => Number})\r\n\tpublic avgRating?: number;\r\n\r\n\t@prop({default: 0,type: ()=> Number})\r\n\tpublic ordersCount?: number\r\n\r\n\t@prop({default: 0,type: ()=> Number})\r\n\tpublic customersCount?: number\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription-setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/subscription-setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,4EAAqE;AACrE,kDAAsE;AAG/D,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,2BAAU;IAO3C,OAAO,CAAuB;IAG9B,MAAM,CAAU;IAGhB,MAAM,CAAU;CACvB,CAAA;AAdY,kDAAmB;AAOxB;IANN,IAAA,gBAAI,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,0BAAmB;KACzB,CAAC;;oDACmC;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAChB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;mDACtC;8BAbX,mBAAmB;IAD/B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,EAAE,CAAC;GAC3D,mBAAmB,CAc/B","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Status, SubscriptionPackage } from '../../../utilities/enum';\n\n@modelOptions({ schemaOptions: { collection: 'subscriptionSettings' } })\nexport class SubscriptionSetting extends TimeStamps {\n\t@prop({\n\t\trequired: true,\n\t\tunique: true,\n\t\ttype: String,\n\t\tenum: SubscriptionPackage,\n\t})\n\tpublic package!: SubscriptionPackage;\n\n\t@prop({ required: true, type: Number })\n\tpublic amount!: number;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"subscription-setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/subscription-setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,4EAAqE;AACrE,kDAAsE;AAG/D,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,2BAAU;IAO3C,OAAO,CAAuB;IAG9B,MAAM,CAAU;IAGhB,MAAM,CAAU;CACvB,CAAA;AAdY,kDAAmB;AAOxB;IANN,IAAA,gBAAI,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,0BAAmB;KACzB,CAAC;;oDACmC;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDAChB;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;mDACtC;8BAbX,mBAAmB;IAD/B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,EAAE,CAAC;GAC3D,mBAAmB,CAc/B","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { Status, SubscriptionPackage } from '../../../utilities/enum';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'subscriptionSettings' } })\r\nexport class SubscriptionSetting extends TimeStamps {\r\n\t@prop({\r\n\t\trequired: true,\r\n\t\tunique: true,\r\n\t\ttype: String,\r\n\t\tenum: SubscriptionPackage,\r\n\t})\r\n\tpublic package!: SubscriptionPackage;\r\n\r\n\t@prop({ required: true, type: Number })\r\n\tpublic amount!: number;\r\n\r\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\r\n\tpublic status?: Status;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.model.js","sourceRoot":"/","sources":["libraries/mongo/models/subscription.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAMiC;AACjC,uDAA6C;AAC7C,sFAA4E;AAC5E,4DAAmD;AACnD,2DAAkD;AAG3C,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,2BAAU;IAEpC,IAAI,CAAiB;IAOrB,OAAO,CAAuB;IAG9B,GAAG,CAAU;IAGb,YAAY,CAAU;IAGtB,OAAO,CAAuB;IAG9B,QAAQ,CAAY;IAOpB,MAAM,CAAsB;IAG5B,SAAS,CAAW;IAGpB,YAAY,CAAU;IAGtB,aAAa,CAAiB;IAG9B,aAAa,CAAiB;IAG9B,YAAY,CAAsB;IAGlC,YAAY,CAAgB;CAC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E,oBAAa,CAAC,OAAO,EAAE,CAAC;;mDACvC;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,+BAAW,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;kDACL;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAY,EAAE,OAAO,EAAE,mBAAY,CAAC,IAAI,EAAE,CAAC;;kDACpC;uBA9CvB,YAAY;IADxB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,CAAC;GACpD,YAAY,CA+CxB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport {\n\tPaidCurrency,\n\tPaymentMethod,\n\tPaymentStatus,\n\tSubscriptionPackage,\n\tSubscriptionStatus,\n} from '../../../utilities/enum';\nimport { CoreUser } from './core-user.model';\nimport { SubscriptionSummary } from './embedded/subscription-summary.model';\nimport { Duration } from './shared/duration.model';\nimport { Transaction } from './transaction.model';\n\n@modelOptions({ schemaOptions: { collection: 'subscriptions' } })\nexport class Subscription extends TimeStamps {\n\t@prop({ required: true, ref: () => CoreUser })\n\tpublic user!: Ref<CoreUser>;\n\n\t@prop({\n\t\ttype: String,\n\t\tenum: SubscriptionPackage,\n\t\tdefault: SubscriptionPackage.MONTHLY,\n\t})\n\tpublic package?: SubscriptionPackage;\n\n\t@prop({ required: true, type: Number })\n\tpublic fee!: number;\n\n\t@prop({ required: true, type: Number })\n\tpublic secondaryFee!: number;\n\n\t@prop({ type: SubscriptionSummary })\n\tpublic summary?: SubscriptionSummary;\n\n\t@prop({ required: true, type: Duration })\n\tpublic duration!: Duration;\n\n\t@prop({\n\t\ttype: String,\n\t\tenum: SubscriptionStatus,\n\t\tdefault: SubscriptionStatus.ONGOING,\n\t})\n\tpublic status?: SubscriptionStatus;\n\n\t@prop({ type: Boolean, default: true })\n\tpublic autoRenew?: boolean;\n\n\t@prop({ type: String })\n\tpublic cancelReason?: string;\n\n\t@prop({ required: true, type: String, enum: PaymentMethod })\n\tpublic paymentMethod!: PaymentMethod;\n\n\t@prop({ type: String, enum: PaymentStatus, default: PaymentStatus.PENDING })\n\tpublic paymentStatus?: PaymentStatus;\n\n\t@prop({ ref: () => Transaction, default: [] })\n\tpublic transactions?: Ref<Transaction>[];\n\n\t@prop({ type: String, enum: PaidCurrency, default: PaidCurrency.BASE })\n\tpublic paidCurrency?: PaidCurrency;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"subscription.model.js","sourceRoot":"/","sources":["libraries/mongo/models/subscription.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAMiC;AACjC,uDAA6C;AAC7C,sFAA4E;AAC5E,4DAAmD;AACnD,2DAAkD;AAG3C,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,2BAAU;IAEpC,IAAI,CAAiB;IAOrB,OAAO,CAAuB;IAG9B,GAAG,CAAU;IAGb,YAAY,CAAU;IAGtB,OAAO,CAAuB;IAG9B,QAAQ,CAAY;IAOpB,MAAM,CAAsB;IAG5B,SAAS,CAAW;IAGpB,YAAY,CAAU;IAGtB,aAAa,CAAiB;IAG9B,aAAa,CAAiB;IAG9B,YAAY,CAAsB;IAGlC,YAAY,CAAgB;CACnC,CAAA;AA/CY,oCAAY;AAEjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,0BAAQ,EAAE,CAAC;;0CAClB;AAOrB;IALN,IAAA,gBAAI,EAAC;QACL,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,0BAAmB;QACzB,OAAO,EAAE,0BAAmB,CAAC,OAAO;KACpC,CAAC;;6CACmC;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAA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aAAa,EAAE,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,CAAC;GACpD,YAAY,CA+CxB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport {\r\n\tPaidCurrency,\r\n\tPaymentMethod,\r\n\tPaymentStatus,\r\n\tSubscriptionPackage,\r\n\tSubscriptionStatus,\r\n} from '../../../utilities/enum';\r\nimport { CoreUser } from './core-user.model';\r\nimport { SubscriptionSummary } from './embedded/subscription-summary.model';\r\nimport { Duration } from './shared/duration.model';\r\nimport { Transaction } from './transaction.model';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'subscriptions' } })\r\nexport class Subscription extends TimeStamps {\r\n\t@prop({ required: true, ref: () => CoreUser })\r\n\tpublic user!: Ref<CoreUser>;\r\n\r\n\t@prop({\r\n\t\ttype: String,\r\n\t\tenum: SubscriptionPackage,\r\n\t\tdefault: SubscriptionPackage.MONTHLY,\r\n\t})\r\n\tpublic package?: SubscriptionPackage;\r\n\r\n\t@prop({ required: true, type: Number })\r\n\tpublic fee!: number;\r\n\r\n\t@prop({ required: true, type: Number })\r\n\tpublic secondaryFee!: number;\r\n\r\n\t@prop({ type: SubscriptionSummary })\r\n\tpublic summary?: SubscriptionSummary;\r\n\r\n\t@prop({ required: true, type: Duration })\r\n\tpublic duration!: Duration;\r\n\r\n\t@prop({\r\n\t\ttype: String,\r\n\t\tenum: SubscriptionStatus,\r\n\t\tdefault: SubscriptionStatus.ONGOING,\r\n\t})\r\n\tpublic status?: SubscriptionStatus;\r\n\r\n\t@prop({ type: Boolean, default: true })\r\n\tpublic autoRenew?: boolean;\r\n\r\n\t@prop({ type: String })\r\n\tpublic cancelReason?: string;\r\n\r\n\t@prop({ required: true, type: String, enum: PaymentMethod })\r\n\tpublic paymentMethod!: PaymentMethod;\r\n\r\n\t@prop({ type: String, enum: PaymentStatus, default: PaymentStatus.PENDING })\r\n\tpublic paymentStatus?: PaymentStatus;\r\n\r\n\t@prop({ ref: () => Transaction, default: [] })\r\n\tpublic transactions?: Ref<Transaction>[];\r\n\r\n\t@prop({ type: String, enum: PaidCurrency, default: PaidCurrency.BASE })\r\n\tpublic paidCurrency?: PaidCurrency;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"support-reason.model.js","sourceRoot":"/","sources":["libraries/mongo/models/support-reason.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAsF;AACtF,oFAAyE;AAiClE,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,2BAAU;IAEpC,MAAM,CAAoB;IAG1B,UAAU,CAAwB;IAGlC,MAAM,CAAuB;IAG7B,YAAY,CAAU;CAC9B,CAAA;AAZY,sCAAa;AAEjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,6CAAiB,EAAE,CAAC;8BACzC,6CAAiB;6CAAC;AAG1B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAAqB,EAAE,CAAC;;iDAC3B;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,2BAAoB,EAAE,CAAC;;6CAC/B;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDACM;wBAXlB,aAAa;IA9BzB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE,CAAC;IACjE,IAAA,eAAG,EAAgB,MAAM,EAAE,KAAK,WAAW,IAAI;QAE9C,MAAM,EAAE,kBAAkB,EAAE,GAAG,wDAAa,GAAG,GAAC,CAAC;QAEjD,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,WAAW,EAAE,CAAC;YAC3D,IAAI,CAAC;gBACH,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC,SAAS,CAA8B;oBACtF;wBACE,MAAM,EAAE;4BACN,UAAU,EAAE,IAAI,CAAC,UAAU;4BAC3B,MAAM,EAAE,2BAAoB,CAAC,MAAM;4BACnC,SAAS,EAAE,IAAI;yBAChB;qBACF;oBACD;wBACE,MAAM,EAAE;4BACN,GAAG,EAAE,IAAI;4BACT,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;yBAC3C;qBACF;iBACF,CAAC,CAAC,IAAI,EAAE,CAAC;gBAEV,IAAI,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACtE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC,KAAc,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QACD,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;GACW,aAAa,CAYzB","sourcesContent":["import { modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { SettingsReasonStatus, SupportReasonTypeEnum } from '../../../utilities/enum';\nimport { SupportReasonInfo } from './embedded/support-reason-info.model';\n\n\n@modelOptions({ schemaOptions: { collection: 'supportReasons' } })\n@pre<SupportReason>('save', async function (next) {\n\n const { SupportReasonModel } = await import('.');\n\n if (this.isNew || typeof this.sortingOrder === 'undefined') {\n try {\n const maxSortingOrder = await SupportReasonModel.aggregate<{ maxSortingOrder: number }>([\n {\n $match: {\n reasonType: this.reasonType,\n status: SettingsReasonStatus.ACTIVE,\n deletedAt: null,\n },\n },\n {\n $group: {\n _id: null,\n maxSortingOrder: { $max: '$sortingOrder' },\n },\n },\n ]).exec();\n\n this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n } catch (error) {\n return next(error as Error);\n }\n }\n next();\n})\nexport class SupportReason extends TimeStamps {\n @prop({ required: true, type: () => SupportReasonInfo })\n public reason: SupportReasonInfo;\n\n @prop({ required: true, type: String, enum: SupportReasonTypeEnum })\n public reasonType: SupportReasonTypeEnum;\n\n @prop({ required: true, type: String, enum: SettingsReasonStatus })\n public status: SettingsReasonStatus;\n\n @prop({ type: Number })\n public sortingOrder?: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"support-reason.model.js","sourceRoot":"/","sources":["libraries/mongo/models/support-reason.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,kDAAsF;AACtF,oFAAyE;AAiClE,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,2BAAU;IAEpC,MAAM,CAAoB;IAG1B,UAAU,CAAwB;IAGlC,MAAM,CAAuB;IAG7B,YAAY,CAAU;CAC9B,CAAA;AAZY,sCAAa;AAEjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,6CAAiB,EAAE,CAAC;8BACzC,6CAAiB;6CAAC;AAG1B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAAqB,EAAE,CAAC;;iDAC3B;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,2BAAoB,EAAE,CAAC;;6CAC/B;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mDACM;wBAXlB,aAAa;IA9BzB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE,CAAC;IACjE,IAAA,eAAG,EAAgB,MAAM,EAAE,KAAK,WAAW,IAAI;QAE9C,MAAM,EAAE,kBAAkB,EAAE,GAAG,wDAAa,GAAG,GAAC,CAAC;QAEjD,IAAI,IAAI,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,WAAW,EAAE,CAAC;YAC3D,IAAI,CAAC;gBACH,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC,SAAS,CAA8B;oBACtF;wBACE,MAAM,EAAE;4BACN,UAAU,EAAE,IAAI,CAAC,UAAU;4BAC3B,MAAM,EAAE,2BAAoB,CAAC,MAAM;4BACnC,SAAS,EAAE,IAAI;yBAChB;qBACF;oBACD;wBACE,MAAM,EAAE;4BACN,GAAG,EAAE,IAAI;4BACT,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;yBAC3C;qBACF;iBACF,CAAC,CAAC,IAAI,EAAE,CAAC;gBAEV,IAAI,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACtE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC,KAAc,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;QACD,IAAI,EAAE,CAAC;IACT,CAAC,CAAC;GACW,aAAa,CAYzB","sourcesContent":["import { modelOptions, pre, prop } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { SettingsReasonStatus, SupportReasonTypeEnum } from '../../../utilities/enum';\r\nimport { SupportReasonInfo } from './embedded/support-reason-info.model';\r\n\r\n\r\n@modelOptions({ schemaOptions: { collection: 'supportReasons' } })\r\n@pre<SupportReason>('save', async function (next) {\r\n\r\n const { SupportReasonModel } = await import('.');\r\n\r\n if (this.isNew || typeof this.sortingOrder === 'undefined') {\r\n try {\r\n const maxSortingOrder = await SupportReasonModel.aggregate<{ maxSortingOrder: number }>([\r\n {\r\n $match: {\r\n reasonType: this.reasonType,\r\n status: SettingsReasonStatus.ACTIVE,\r\n deletedAt: null,\r\n },\r\n },\r\n {\r\n $group: {\r\n _id: null,\r\n maxSortingOrder: { $max: '$sortingOrder' },\r\n },\r\n },\r\n ]).exec();\r\n\r\n this.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\r\n } catch (error) {\r\n return next(error as Error);\r\n }\r\n }\r\n next();\r\n})\r\nexport class SupportReason extends TimeStamps {\r\n @prop({ required: true, type: () => SupportReasonInfo })\r\n public reason: SupportReasonInfo;\r\n\r\n @prop({ required: true, type: String, enum: SupportReasonTypeEnum })\r\n public reasonType: SupportReasonTypeEnum;\r\n\r\n @prop({ required: true, type: String, enum: SettingsReasonStatus })\r\n public status: SettingsReasonStatus;\r\n\r\n @prop({ type: Number })\r\n public sortingOrder?: number;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.model.js","sourceRoot":"/","sources":["libraries/mongo/models/tag.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,kDAA2D;AAC3D,wBAA6B;AAsGtB,IAAM,GAAG,GAAT,MAAM,GAAG;IAER,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,QAAQ,CAAY;IAGpB,MAAM,CAAU;IAGhB,SAAS,CAAW;IAGpB,YAAY,CAAU;CAC7B,CAAA;AAlBY,kBAAG;AAER;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;;iCAC7C;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCACjB;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,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IAAI;QACxE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAS,CAAC;QAEvC,IAAI,MAAM,EAAE,MAAM,KAAK,aAAM,CAAC,MAAM,EAAE,CAAC;YAEtC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAEtD,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,aAAM,CAAC,MAAM,EAAE,CAAC;gBAEzC,MAAM,eAAe,GAAG,MAAM,WAAQ,CAAC,SAAS,CAA8B;oBAC7E;wBACC,MAAM,EAAE;4BACP,QAAQ,EAAE,GAAG,CAAC,QAAQ;4BACtB,MAAM,EAAE,aAAM,CAAC,MAAM;4BACrB,SAAS,EAAE,IAAI;yBACf;qBACD;oBACD;wBACC,MAAM,EAAE;4BACP,GAAG,EAAE,IAAI;4BACT,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;yBAC1C;qBACD;iBACD,CAAC,CAAC,IAAI,EAAE,CAAC;gBAGV,MAAM,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAGtE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC;QACF,CAAC;QAED,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,GAAG,CAkBf","sourcesContent":["import { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { ItemType, Status } from '../../../utilities/enum';\nimport { TagModel } from '.';\nimport { Query } from 'mongoose';\n\n@modelOptions({ schemaOptions: { collection: 'tags' } })\n@Index({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@Index({ itemType: 1, deletedAt: 1 })\n@pre<Tag>('save', async function (next) {\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\n\t\ttry {\n\t\t\t// Find the maximum sortingOrder for tags with the same itemType that aren't deleted\n\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\titemType: this.itemType,\n\t\t\t\t\t\tstatus: Status.ACTIVE,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t} catch (error) {\n\t\t\treturn next(error as Error);\n\t\t}\n\t}\n\n\t// Add this code to handle status change from inactive to active\n\tif (this.isModified('status') && this.status === Status.ACTIVE) {\n\t\t// Check if status was previously inactive\n\t\tconst original = await TagModel.findById(this._id);\n\t\tif (original && original.status !== Status.ACTIVE) {\n\t\t\ttry {\n\t\t\t\t// Find the maximum sortingOrder for active tags with the same itemType\n\t\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\titemType: this.itemType,\n\t\t\t\t\t\t\tstatus: Status.ACTIVE,\n\t\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t]).exec();\n\n\t\t\t\t// Set the sortingOrder to max + 1 (or 0 if no items found)\n\t\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t\t} catch (error) {\n\t\t\t\treturn next(error as Error);\n\t\t\t}\n\t\t}\n\t}\n\n\tnext();\n})\n@pre<Tag>('findOneAndUpdate', async function (this: Query<any, Tag>, next) {\n\tconst update = this.getUpdate() as any;\n\n\tif (update?.status === Status.ACTIVE) {\n\t\t// Get current document (before update)\n\t\tconst tag = await this.model.findOne(this.getQuery());\n\n\t\tif (tag && tag.status !== Status.ACTIVE) {\n\t\t\t// Find the maximum sortingOrder for active tags with the same itemType\n\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\titemType: tag.itemType,\n\t\t\t\t\t\tstatus: Status.ACTIVE,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tupdate.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\n\t\t\t// Inject the new sortingOrder into the update\n\t\t\tthis.setUpdate(update);\n\t\t}\n\t}\n\n\tnext();\n})\nexport class Tag {\n\t@prop({ required: true, type: String, trim: true, maxlength: 30 })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic image!: string;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\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"]}
|
|
1
|
+
{"version":3,"file":"tag.model.js","sourceRoot":"/","sources":["libraries/mongo/models/tag.model.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eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAGtE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC;QACF,CAAC;QAED,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,GAAG,CAkBf","sourcesContent":["import { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\r\nimport { ItemType, Status } from '../../../utilities/enum';\r\nimport { TagModel } from '.';\r\nimport { Query } from 'mongoose';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'tags' } })\r\n@Index({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\r\n@Index({ itemType: 1, deletedAt: 1 })\r\n@pre<Tag>('save', async function (next) {\r\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\r\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\r\n\t\ttry {\r\n\t\t\t// Find the maximum sortingOrder for tags with the same itemType that aren't deleted\r\n\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\r\n\t\t\t\t{\r\n\t\t\t\t\t$match: {\r\n\t\t\t\t\t\titemType: this.itemType,\r\n\t\t\t\t\t\tstatus: Status.ACTIVE,\r\n\t\t\t\t\t\tdeletedAt: null,\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t$group: {\r\n\t\t\t\t\t\t_id: null,\r\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t]).exec();\r\n\r\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\r\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\r\n\t\t} catch (error) {\r\n\t\t\treturn next(error as Error);\r\n\t\t}\r\n\t}\r\n\r\n\t// Add this code to handle status change from inactive to active\r\n\tif (this.isModified('status') && this.status === Status.ACTIVE) {\r\n\t\t// Check if status was previously inactive\r\n\t\tconst original = await TagModel.findById(this._id);\r\n\t\tif (original && original.status !== Status.ACTIVE) {\r\n\t\t\ttry {\r\n\t\t\t\t// Find the maximum sortingOrder for active tags with the same itemType\r\n\t\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t$match: {\r\n\t\t\t\t\t\t\titemType: this.itemType,\r\n\t\t\t\t\t\t\tstatus: Status.ACTIVE,\r\n\t\t\t\t\t\t\tdeletedAt: null,\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t$group: {\r\n\t\t\t\t\t\t\t_id: null,\r\n\t\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t},\r\n\t\t\t\t]).exec();\r\n\r\n\t\t\t\t// Set the sortingOrder to max + 1 (or 0 if no items found)\r\n\t\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\r\n\t\t\t} catch (error) {\r\n\t\t\t\treturn next(error as Error);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tnext();\r\n})\r\n@pre<Tag>('findOneAndUpdate', async function (this: Query<any, Tag>, next) {\r\n\tconst update = this.getUpdate() as any;\r\n\r\n\tif (update?.status === Status.ACTIVE) {\r\n\t\t// Get current document (before update)\r\n\t\tconst tag = await this.model.findOne(this.getQuery());\r\n\r\n\t\tif (tag && tag.status !== Status.ACTIVE) {\r\n\t\t\t// Find the maximum sortingOrder for active tags with the same itemType\r\n\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\r\n\t\t\t\t{\r\n\t\t\t\t\t$match: {\r\n\t\t\t\t\t\titemType: tag.itemType,\r\n\t\t\t\t\t\tstatus: Status.ACTIVE,\r\n\t\t\t\t\t\tdeletedAt: null,\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t$group: {\r\n\t\t\t\t\t\t_id: null,\r\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t]).exec();\r\n\r\n\t\t\t// Set the sortingOrder to max + 1 (or 0 if no items found)\r\n\t\t\tupdate.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\r\n\r\n\t\t\t// Inject the new sortingOrder into the update\r\n\t\t\tthis.setUpdate(update);\r\n\t\t}\r\n\t}\r\n\r\n\tnext();\r\n})\r\nexport class Tag {\r\n\t@prop({ required: true, type: String, trim: true, maxlength: 30 })\r\n\tpublic name!: string;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic image!: string;\r\n\r\n\t@prop({ required: true, type: String, enum: ItemType })\r\n\tpublic itemType!: ItemType;\r\n\r\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\r\n\tpublic status?: Status;\r\n\r\n\t@prop({ type: Boolean, default: true })\r\n\tpublic isVisible?: boolean;\r\n\r\n\t@prop({ type: Number })\r\n\tpublic sortingOrder?: number;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terms-and-conditions.model.js","sourceRoot":"/","sources":["libraries/mongo/models/terms-and-conditions.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,4EAAqE;AAQ9D,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,2BAAU;IAE1C,cAAc,CAAS;IAGvB,sBAAsB,CAAS;IAG/B,sBAAsB,CAAS;IAG/B,uBAAuB,CAAS;IAGhC,0BAA0B,CAAS;CAC1C,CAAA;AAfY,gDAAkB;AAEvB;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;0DACQ;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;kEACgB;AAG/B;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;kEACgB;AAG/B;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;mEACiB;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;sEACoB;6BAd9B,kBAAkB;IAN9B,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE;YACd,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,IAAI;SAChB;KACD,CAAC;GACW,kBAAkB,CAe9B","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\n\n@modelOptions({\n\tschemaOptions: {\n\t\tcollection: 'terms-and-conditions',\n\t\ttimestamps: true,\n\t},\n})\nexport class TermsAndConditions extends TimeStamps {\n\t@prop({ default: '' })\n\tpublic privacyMessage: string;\n\n\t@prop({ default: '' })\n\tpublic userTermsAndConditions: string;\n\n\t@prop({ default: '' })\n\tpublic shopTermsAndConditions: string;\n\n\t@prop({ default: '' })\n\tpublic riderTermsAndConditions: string;\n\n\t@prop({ default: '' })\n\tpublic lyxaPlusTermsAndConditions: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"terms-and-conditions.model.js","sourceRoot":"/","sources":["libraries/mongo/models/terms-and-conditions.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,4EAAqE;AAQ9D,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,2BAAU;IAE1C,cAAc,CAAS;IAGvB,sBAAsB,CAAS;IAG/B,sBAAsB,CAAS;IAG/B,uBAAuB,CAAS;IAGhC,0BAA0B,CAAS;CAC1C,CAAA;AAfY,gDAAkB;AAEvB;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;0DACQ;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;kEACgB;AAG/B;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;kEACgB;AAG/B;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;mEACiB;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;sEACoB;6BAd9B,kBAAkB;IAN9B,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE;YACd,UAAU,EAAE,sBAAsB;YAClC,UAAU,EAAE,IAAI;SAChB;KACD,CAAC;GACW,kBAAkB,CAe9B","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\n\r\n@modelOptions({\r\n\tschemaOptions: {\r\n\t\tcollection: 'terms-and-conditions',\r\n\t\ttimestamps: true,\r\n\t},\r\n})\r\nexport class TermsAndConditions extends TimeStamps {\r\n\t@prop({ default: '' })\r\n\tpublic privacyMessage: string;\r\n\r\n\t@prop({ default: '' })\r\n\tpublic userTermsAndConditions: string;\r\n\r\n\t@prop({ default: '' })\r\n\tpublic shopTermsAndConditions: string;\r\n\r\n\t@prop({ default: '' })\r\n\tpublic riderTermsAndConditions: string;\r\n\r\n\t@prop({ default: '' })\r\n\tpublic lyxaPlusTermsAndConditions: string;\r\n}\r\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Ref } from '@typegoose/typegoose';
|
|
2
|
+
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
|
+
import { User } from './user.model';
|
|
4
|
+
import { Shop } from './shop.model';
|
|
5
|
+
import { Order } from './order.model';
|
|
6
|
+
import { Admin } from './admin.model';
|
|
7
|
+
import { TicketType, TicketStatus } from '../../../utilities/enum';
|
|
8
|
+
import { Chatroom } from './chat-room.model';
|
|
9
|
+
export declare class Ticket extends TimeStamps {
|
|
10
|
+
ticketId: string;
|
|
11
|
+
type: TicketType;
|
|
12
|
+
status: TicketStatus;
|
|
13
|
+
client: Ref<User | Shop>;
|
|
14
|
+
clientType: string;
|
|
15
|
+
subject: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
order?: Ref<Order>;
|
|
18
|
+
assignedAgent?: Ref<Admin>;
|
|
19
|
+
assignedAt?: Date;
|
|
20
|
+
assignmentAttempts?: number;
|
|
21
|
+
chatroom: Ref<Chatroom>;
|
|
22
|
+
resolvedAt?: Date;
|
|
23
|
+
closedAt?: Date;
|
|
24
|
+
resolutionTimeMinutes?: number;
|
|
25
|
+
customerRating?: number;
|
|
26
|
+
customerFeedback?: string;
|
|
27
|
+
agentScore?: number;
|
|
28
|
+
tags?: string[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.Ticket = void 0;
|
|
46
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
|
47
|
+
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
48
|
+
const order_model_1 = require("./order.model");
|
|
49
|
+
const admin_model_1 = require("./admin.model");
|
|
50
|
+
const enum_1 = require("../../../utilities/enum");
|
|
51
|
+
const chat_room_model_1 = require("./chat-room.model");
|
|
52
|
+
let Ticket = class Ticket extends defaultClasses_1.TimeStamps {
|
|
53
|
+
ticketId;
|
|
54
|
+
type;
|
|
55
|
+
status;
|
|
56
|
+
client;
|
|
57
|
+
clientType;
|
|
58
|
+
subject;
|
|
59
|
+
description;
|
|
60
|
+
order;
|
|
61
|
+
assignedAgent;
|
|
62
|
+
assignedAt;
|
|
63
|
+
assignmentAttempts;
|
|
64
|
+
chatroom;
|
|
65
|
+
resolvedAt;
|
|
66
|
+
closedAt;
|
|
67
|
+
resolutionTimeMinutes;
|
|
68
|
+
customerRating;
|
|
69
|
+
customerFeedback;
|
|
70
|
+
agentScore;
|
|
71
|
+
tags;
|
|
72
|
+
};
|
|
73
|
+
exports.Ticket = Ticket;
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typegoose_1.prop)({ required: true, type: String, unique: true }),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], Ticket.prototype, "ticketId", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.TicketType }),
|
|
80
|
+
__metadata("design:type", String)
|
|
81
|
+
], Ticket.prototype, "type", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.TicketStatus, default: enum_1.TicketStatus.PENDING }),
|
|
84
|
+
__metadata("design:type", String)
|
|
85
|
+
], Ticket.prototype, "status", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, typegoose_1.prop)({ refPath: 'clientType', required: true }),
|
|
88
|
+
__metadata("design:type", Object)
|
|
89
|
+
], Ticket.prototype, "client", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, typegoose_1.prop)({ required: true, type: String, enum: ['User', 'Shop'] }),
|
|
92
|
+
__metadata("design:type", String)
|
|
93
|
+
], Ticket.prototype, "clientType", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, typegoose_1.prop)({ type: String, required: true }),
|
|
96
|
+
__metadata("design:type", String)
|
|
97
|
+
], Ticket.prototype, "subject", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, typegoose_1.prop)({ type: String }),
|
|
100
|
+
__metadata("design:type", String)
|
|
101
|
+
], Ticket.prototype, "description", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, typegoose_1.prop)({ ref: () => order_model_1.Order }),
|
|
104
|
+
__metadata("design:type", Object)
|
|
105
|
+
], Ticket.prototype, "order", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
(0, typegoose_1.prop)({ ref: () => admin_model_1.Admin }),
|
|
108
|
+
__metadata("design:type", Object)
|
|
109
|
+
], Ticket.prototype, "assignedAgent", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, typegoose_1.prop)({ type: Date }),
|
|
112
|
+
__metadata("design:type", Date)
|
|
113
|
+
], Ticket.prototype, "assignedAt", void 0);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
116
|
+
__metadata("design:type", Number)
|
|
117
|
+
], Ticket.prototype, "assignmentAttempts", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
(0, typegoose_1.prop)({ ref: () => chat_room_model_1.Chatroom, required: true }),
|
|
120
|
+
__metadata("design:type", Object)
|
|
121
|
+
], Ticket.prototype, "chatroom", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, typegoose_1.prop)({ type: Date }),
|
|
124
|
+
__metadata("design:type", Date)
|
|
125
|
+
], Ticket.prototype, "resolvedAt", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
(0, typegoose_1.prop)({ type: Date }),
|
|
128
|
+
__metadata("design:type", Date)
|
|
129
|
+
], Ticket.prototype, "closedAt", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
(0, typegoose_1.prop)({ type: Number }),
|
|
132
|
+
__metadata("design:type", Number)
|
|
133
|
+
], Ticket.prototype, "resolutionTimeMinutes", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
(0, typegoose_1.prop)({ type: Number, min: 1, max: 5 }),
|
|
136
|
+
__metadata("design:type", Number)
|
|
137
|
+
], Ticket.prototype, "customerRating", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
(0, typegoose_1.prop)({ type: String }),
|
|
140
|
+
__metadata("design:type", String)
|
|
141
|
+
], Ticket.prototype, "customerFeedback", void 0);
|
|
142
|
+
__decorate([
|
|
143
|
+
(0, typegoose_1.prop)({ type: Number }),
|
|
144
|
+
__metadata("design:type", Number)
|
|
145
|
+
], Ticket.prototype, "agentScore", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, typegoose_1.prop)({ type: [String], default: [] }),
|
|
148
|
+
__metadata("design:type", Array)
|
|
149
|
+
], Ticket.prototype, "tags", void 0);
|
|
150
|
+
exports.Ticket = Ticket = __decorate([
|
|
151
|
+
(0, typegoose_1.pre)('save', async function (next) {
|
|
152
|
+
if (this.isNew && !this.ticketId) {
|
|
153
|
+
const { CounterModel } = await Promise.resolve().then(() => __importStar(require('.')));
|
|
154
|
+
try {
|
|
155
|
+
const counter = await CounterModel.findOneAndUpdate({ counterType: 'ticket' }, { $inc: { value: 1 } }, { new: true, upsert: true });
|
|
156
|
+
const currentDate = new Date().toISOString().slice(0, 10).replace(/-/g, '');
|
|
157
|
+
this.ticketId = `TKT-${currentDate}-${String(counter.value).padStart(4, '0')}`;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
return next(error);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
next();
|
|
164
|
+
}),
|
|
165
|
+
(0, typegoose_1.modelOptions)({
|
|
166
|
+
schemaOptions: {
|
|
167
|
+
collection: 'tickets',
|
|
168
|
+
timestamps: true,
|
|
169
|
+
},
|
|
170
|
+
}),
|
|
171
|
+
(0, typegoose_1.index)({ assignedAgent: 1, status: 1 }),
|
|
172
|
+
(0, typegoose_1.index)({ type: 1, status: 1, priority: 1 }),
|
|
173
|
+
(0, typegoose_1.index)({ client: 1, clientType: 1, status: 1 }),
|
|
174
|
+
(0, typegoose_1.index)({ createdAt: -1 }),
|
|
175
|
+
(0, typegoose_1.index)({ ticketId: 1 }, { unique: true }),
|
|
176
|
+
(0, typegoose_1.index)({ chatroom: 1 })
|
|
177
|
+
], Ticket);
|
|
178
|
+
//# sourceMappingURL=ticket.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ticket.model.js","sourceRoot":"/","sources":["libraries/mongo/models/ticket.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAiF;AACjF,4EAAqE;AAGrE,+CAAsC;AACtC,+CAAsC;AACtC,kDAAmE;AACnE,uDAA6C;AAiCtC,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,2BAAU;IAE9B,QAAQ,CAAU;IAGlB,IAAI,CAAc;IAGlB,MAAM,CAAgB;IAGtB,MAAM,CAAoB;IAG1B,UAAU,CAAU;IAGpB,OAAO,CAAU;IAGjB,WAAW,CAAU;IAGrB,KAAK,CAAc;IAGnB,aAAa,CAAc;IAG3B,UAAU,CAAQ;IAGlB,kBAAkB,CAAU;IAG5B,QAAQ,CAAiB;IAGzB,UAAU,CAAQ;IAGlB,QAAQ,CAAQ;IAGhB,qBAAqB,CAAU;IAG/B,cAAc,CAAU;IAGxB,gBAAgB,CAAU;IAG1B,UAAU,CAAU;IAGpB,IAAI,CAAY;CACvB,CAAA;AAzDY,wBAAM;AAEX;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;wCAC5B;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAU,EAAE,CAAC;;oCAChC;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,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;YAC7B,CAAC;QACF,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE;YACd,UAAU,EAAE,SAAS;YACrB,UAAU,EAAE,IAAI;SAChB;KACD,CAAC;IACD,IAAA,iBAAK,EAAC,EAAE,aAAa,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IACtC,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;IAC1C,IAAA,iBAAK,EAAC,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC9C,IAAA,iBAAK,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC;IACxB,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACxC,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;GACV,MAAM,CAyDlB","sourcesContent":["import { prop, Ref, index, modelOptions, pre, post } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { User } from './user.model';\r\nimport { Shop } from './shop.model';\r\nimport { Order } from './order.model';\r\nimport { Admin } from './admin.model';\r\nimport { TicketType, TicketStatus } from '../../../utilities/enum';\r\nimport { Chatroom } from './chat-room.model';\r\n\r\n@pre<Ticket>('save', async function (next) {\r\n\tif (this.isNew && !this.ticketId) {\r\n\t\tconst { CounterModel } = await import('.');\r\n\r\n\t\ttry {\r\n\t\t\tconst counter = await CounterModel.findOneAndUpdate(\r\n\t\t\t\t{ counterType: 'ticket' },\r\n\t\t\t\t{ $inc: { value: 1 } },\r\n\t\t\t\t{ new: true, upsert: true }\r\n\t\t\t);\r\n\r\n\t\t\tconst currentDate = new Date().toISOString().slice(0, 10).replace(/-/g, '');\r\n\t\t\tthis.ticketId = `TKT-${currentDate}-${String(counter.value).padStart(4, '0')}`;\r\n\t\t} catch (error) {\r\n\t\t\treturn next(error as Error);\r\n\t\t}\r\n\t}\r\n\tnext();\r\n})\r\n@modelOptions({\r\n\tschemaOptions: {\r\n\t\tcollection: 'tickets',\r\n\t\ttimestamps: true,\r\n\t},\r\n})\r\n@index({ assignedAgent: 1, status: 1 })\r\n@index({ type: 1, status: 1, priority: 1 })\r\n@index({ client: 1, clientType: 1, status: 1 })\r\n@index({ createdAt: -1 })\r\n@index({ ticketId: 1 }, { unique: true })\r\n@index({ chatroom: 1 })\r\nexport class Ticket extends TimeStamps {\r\n\t@prop({ required: true, type: String, unique: true })\r\n\tpublic ticketId!: string;\r\n\r\n\t@prop({ required: true, type: String, enum: TicketType })\r\n\tpublic type!: TicketType;\r\n\r\n\t@prop({ required: true, type: String, enum: TicketStatus, default: TicketStatus.PENDING })\r\n\tpublic status!: TicketStatus;\r\n\r\n\t@prop({ refPath: 'clientType', required: true })\r\n\tpublic client!: Ref<User | Shop>;\r\n\r\n\t@prop({ required: true, type: String, enum: ['User', 'Shop'] })\r\n\tpublic clientType!: string;\r\n\r\n\t@prop({ type: String, required: true })\r\n\tpublic subject!: string;\r\n\r\n\t@prop({ type: String })\r\n\tpublic description?: string;\r\n\r\n\t@prop({ ref: () => Order })\r\n\tpublic order?: Ref<Order>;\r\n\r\n\t@prop({ ref: () => Admin })\r\n\tpublic assignedAgent?: Ref<Admin>;\r\n\r\n\t@prop({ type: Date })\r\n\tpublic assignedAt?: Date;\r\n\r\n\t@prop({ type: Number, default: 0 })\r\n\tpublic assignmentAttempts?: number;\r\n\r\n\t@prop({ ref: () => Chatroom, required: true })\r\n\tpublic chatroom!: Ref<Chatroom>;\r\n\r\n\t@prop({ type: Date })\r\n\tpublic resolvedAt?: Date;\r\n\r\n\t@prop({ type: Date })\r\n\tpublic closedAt?: Date;\r\n\r\n\t@prop({ type: Number })\r\n\tpublic resolutionTimeMinutes?: number;\r\n\r\n\t@prop({ type: Number, min: 1, max: 5 })\r\n\tpublic customerRating?: number;\r\n\r\n\t@prop({ type: String })\r\n\tpublic customerFeedback?: string;\r\n\r\n\t@prop({ type: Number })\r\n\tpublic agentScore?: number;\r\n\r\n\t@prop({ type: [String], default: [] })\r\n\tpublic tags?: string[];\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.model.js","sourceRoot":"/","sources":["libraries/mongo/models/transaction.model.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;CAAG;AAA3B,kCAA2B","sourcesContent":["export class Transaction {}\n"]}
|
|
1
|
+
{"version":3,"file":"transaction.model.js","sourceRoot":"/","sources":["libraries/mongo/models/transaction.model.ts"],"names":[],"mappings":";;;AAAA,MAAa,WAAW;CAAG;AAA3B,kCAA2B","sourcesContent":["export class Transaction {}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-app-section-setting.model.js","sourceRoot":"/","sources":["libraries/mongo/models/user-app-section-setting.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,kDAA6F;AAC7F,wBAA+C;AAkCxC,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,2BAAU;IAE7C,QAAQ,CAA0B;IAGlC,OAAO,CAAsB;IAG7B,KAAK,CAAU;IAGf,MAAM,CAAU;IAGhB,YAAY,CAAU;CAC7B,CAAA;AAfY,sDAAqB;AAE1B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,6BAAsB,EAAE,CAAC;;uDAC5B;AAGlC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAkB,EAAE,CAAC;;sDAC7B;AAG7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,qBAAqB,CAejC","sourcesContent":["import { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Status, UserAppSectionItemType, UserAppSectionType } from '../../../utilities/enum';\nimport { UserAppSectionSettingModel } from '.';\n\n@modelOptions({ schemaOptions: { collection: 'userAppSectionSetting'} })\n@Index(\n\t{ itemType: 1, section: 1 },\n\t{ unique: true }\n)\n@pre<UserAppSectionSetting>('save', async function (next) {\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\n\t\ttry {\n\t\t\t// Find the maximum sortingOrder that aren't deleted\n\t\t\tconst maxSortingOrder = await UserAppSectionSettingModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t} catch (error) {\n\t\t\treturn next(error as Error);\n\t\t}\n\t}\n\tnext();\n})\nexport class UserAppSectionSetting extends TimeStamps {\n\t@prop({ required: true, type: String, enum: UserAppSectionItemType })\n\tpublic itemType!: UserAppSectionItemType;\n\n\t@prop({ required: true, type: String, enum: UserAppSectionType })\n\tpublic section!: UserAppSectionType;\n\n\t@prop({ required: true, type: String })\n\tpublic alias!: string;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"user-app-section-setting.model.js","sourceRoot":"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,EAAE,CAAC;YAC5D,IAAI,CAAC;gBAEJ,MAAM,eAAe,GAAG,MAAM,6BAA0B,CAAC,SAAS,CAA8B;oBAC/F;wBACC,MAAM,EAAE;4BACP,SAAS,EAAE,IAAI;yBACf;qBACD;oBACD;wBACC,MAAM,EAAE;4BACP,GAAG,EAAE,IAAI;4BACT,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;yBAC1C;qBACD;iBACD,CAAC,CAAC,IAAI,EAAE,CAAC;gBAGV,IAAI,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACrE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,KAAc,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,qBAAqB,CAejC","sourcesContent":["import { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { Status, UserAppSectionItemType, UserAppSectionType } from '../../../utilities/enum';\r\nimport { UserAppSectionSettingModel } from '.';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'userAppSectionSetting'} })\r\n@Index(\r\n\t{ itemType: 1, section: 1 },\r\n\t{ unique: true }\r\n)\r\n@pre<UserAppSectionSetting>('save', async function (next) {\r\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\r\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\r\n\t\ttry {\r\n\t\t\t// Find the maximum sortingOrder that aren't deleted\r\n\t\t\tconst maxSortingOrder = await UserAppSectionSettingModel.aggregate<{ maxSortingOrder: number }>([\r\n\t\t\t\t{\r\n\t\t\t\t\t$match: {\r\n\t\t\t\t\t\tdeletedAt: null,\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t$group: {\r\n\t\t\t\t\t\t_id: null,\r\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t]).exec();\r\n\r\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\r\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\r\n\t\t} catch (error) {\r\n\t\t\treturn next(error as Error);\r\n\t\t}\r\n\t}\r\n\tnext();\r\n})\r\nexport class UserAppSectionSetting extends TimeStamps {\r\n\t@prop({ required: true, type: String, enum: UserAppSectionItemType })\r\n\tpublic itemType!: UserAppSectionItemType;\r\n\r\n\t@prop({ required: true, type: String, enum: UserAppSectionType })\r\n\tpublic section!: UserAppSectionType;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic alias!: string;\r\n\r\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\r\n\tpublic status?: Status;\r\n\r\n\t@prop({ type: Number })\r\n\tpublic sortingOrder?: number;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.model.js","sourceRoot":"/","sources":["libraries/mongo/models/user.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,oDAAiG;AACjG,4EAAqE;AACrE,uDAA6C;AAC7C,mDAA0C;AAC1C,6CAAoC;AACpC,0DAAqD;AACrD,iDAAwC;AACxC,6DAAoD;AACpD,kDAAiD;AACjD,kEAAwD;AAIjD,IAAM,IAAI,YAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,QAAQ,CAAiB;IAGzB,gBAAgB,CAAkB;IAGlC,aAAa,CAAe;IAG5B,SAAS,CAAiB;IAG1B,MAAM,CAAU;IAGhB,cAAc,CAAU;IAGxB,eAAe,CAAQ;IAGvB,aAAa,CAAU;IAGvB,OAAO,CAAiB;IAGxB,yBAAyB,CAAU;IAGnC,kBAAkB,CAAU;IAG5B,iCAAiC,CAAU;IAG3C,qBAAqB,CA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,EAAE,CAAC;IAC/B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;GAC5C,IAAI,CA6DhB","sourcesContent":["import { index, modelOptions, mongoose, prop, Ref, ReturnModelType } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { CoreUser } from './core-user.model';\nimport { Product } from './product.model';\nimport { Shop } from './shop.model';\nimport { UserAddress } from './shared/address.model';\nimport { Coupon } from './coupon.model';\nimport { Subscription } from './subscription.model';\nimport { Status } from '../../../utilities/enum';\nimport { OTPFields } from './embedded/otp-fields.model';\n\n@index({ location: '2dsphere' })\n@modelOptions({ schemaOptions: { collection: 'users' } })\nexport class User extends TimeStamps {\n\t@prop({ required: true, ref: () => CoreUser })\n\tpublic coreUser!: Ref<CoreUser>;\n\n\t@prop({ type: () => [String], ref: () => Product })\n\tpublic favoriteProducts?: Ref<Product>[];\n\n\t@prop({ type: () => [String], ref: () => Shop })\n\tpublic favoriteShops?: Ref<Shop>[];\n\n\t@prop({ type: () => [UserAddress] })\n\tpublic addresses?: UserAddress[];\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic orderCompleted?: number;\n\n\t@prop({ type: Date })\n\tpublic repeatedOrderAt?: Date;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic walletBalance?: number;\n\n\t@prop({ ref: () => Coupon })\n\tpublic coupons?: Ref<Coupon>[];\n\n\t@prop({ type: String })\n\tpublic newUserCouponDiscountType?: string;\n\n\t@prop({ type: Number })\n\tpublic newUserCouponValue?: number;\n\n\t@prop({ type: Number })\n\tpublic newUserCouponMaximumDiscountLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isNewUserCouponShowed?: boolean;\n\n\t@prop({ type: String, ref: () => Coupon })\n\tpublic referralCode?: Ref<Coupon>;\n\n\t@prop({ type: String, ref: () => Subscription })\n\tpublic subscription?: Ref<Subscription>;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSubscribed?: boolean;\n\n\t@prop({ type: String, unique: true, sparse: true })\n\tpublic phoneNumber?: string;\n\n\t@prop({ type: () => OTPFields })\n\tpublic phoneOtpInfo?: OTPFields;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isPhoneVerified?: boolean;\n\n\tpublic static async updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number) {\n\t\treturn this.findByIdAndUpdate(userId, { $inc: { walletBalance: amount } }, { new: true });\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"user.model.js","sourceRoot":"/","sources":["libraries/mongo/models/user.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,oDAAiG;AACjG,4EAAqE;AACrE,uDAA6C;AAC7C,mDAA0C;AAC1C,6CAAoC;AACpC,0DAAqD;AACrD,iDAAwC;AACxC,6DAAoD;AACpD,kDAAiD;AACjD,kEAAwD;AAIjD,IAAM,IAAI,YAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,QAAQ,CAAiB;IAGzB,gBAAgB,CAAkB;IAGlC,aAAa,CAAe;IAG5B,SAAS,CAAiB;IAG1B,MAAM,CAAU;IAGhB,cAAc,CAAU;IAGxB,eAAe,CAAQ;IAGvB,aAAa,CAAU;IAGvB,OAAO,CAAiB;IAGxB,yBAAyB,CAAU;IAGnC,kBAAkB,CAAU;IAG5B,iCAAiC,CAAU;IAG3C,qBAAqB,CAAW;IAGhC,YAAY,CAAe;IAG3B,YAAY,CAAqB;IAGjC,YAAY,CAAW;IAGvB,WAAW,CAAU;IAGrB,YAAY,CAAa;IAGzB,eAAe,CAAW;IAE1B,MAAM,CAAC,KAAK,CAAC,YAAY,CAAqC,MAAc,EAAE,MAAc;QAClG,OAAO,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,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M,EAAE,CAAC;;gDACY;AAG5B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+DAC2B;AAG3C;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;mDACD;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,qBAAM,EAAE,CAAC;;0CACR;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iCAAY,EAAE,CAAC;;0CACR;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;0CACV;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;yCACvB;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,4BAAS,EAAE,CAAC;8BACV,4BAAS;0CAAC;AAGzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;6CACP;eAxDrB,IAAI;IAFhB,IAAA,iBAAK,EAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAC/B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;GAC5C,IAAI,CA6DhB","sourcesContent":["import { index, modelOptions, mongoose, prop, Ref, ReturnModelType } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { CoreUser } from './core-user.model';\r\nimport { Product } from './product.model';\r\nimport { Shop } from './shop.model';\r\nimport { UserAddress } from './shared/address.model';\r\nimport { Coupon } from './coupon.model';\r\nimport { Subscription } from './subscription.model';\r\nimport { Status } from '../../../utilities/enum';\r\nimport { OTPFields } from './embedded/otp-fields.model';\r\n\r\n@index({ location: '2dsphere' })\r\n@modelOptions({ schemaOptions: { collection: 'users' } })\r\nexport class User extends TimeStamps {\r\n\t@prop({ required: true, ref: () => CoreUser })\r\n\tpublic coreUser!: Ref<CoreUser>;\r\n\r\n\t@prop({ type: () => [String], ref: () => Product })\r\n\tpublic favoriteProducts?: Ref<Product>[];\r\n\r\n\t@prop({ type: () => [String], ref: () => Shop })\r\n\tpublic favoriteShops?: Ref<Shop>[];\r\n\r\n\t@prop({ type: () => [UserAddress] })\r\n\tpublic addresses?: UserAddress[];\r\n\r\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\r\n\tpublic status?: Status;\r\n\r\n\t@prop({ type: Number, default: 0 })\r\n\tpublic orderCompleted?: number;\r\n\r\n\t@prop({ type: Date })\r\n\tpublic repeatedOrderAt?: Date;\r\n\r\n\t@prop({ type: Number, default: 0 })\r\n\tpublic walletBalance?: number;\r\n\r\n\t@prop({ ref: () => Coupon })\r\n\tpublic coupons?: Ref<Coupon>[];\r\n\r\n\t@prop({ type: String })\r\n\tpublic newUserCouponDiscountType?: string;\r\n\r\n\t@prop({ type: Number })\r\n\tpublic newUserCouponValue?: number;\r\n\r\n\t@prop({ type: Number })\r\n\tpublic newUserCouponMaximumDiscountLimit?: number;\r\n\r\n\t@prop({ type: Boolean, default: false })\r\n\tpublic isNewUserCouponShowed?: boolean;\r\n\r\n\t@prop({ type: String, ref: () => Coupon })\r\n\tpublic referralCode?: Ref<Coupon>;\r\n\r\n\t@prop({ type: String, ref: () => Subscription })\r\n\tpublic subscription?: Ref<Subscription>;\r\n\r\n\t@prop({ type: Boolean, default: false })\r\n\tpublic isSubscribed?: boolean;\r\n\r\n\t@prop({ type: String, unique: true, sparse: true })\r\n\tpublic phoneNumber?: string;\r\n\r\n\t@prop({ type: () => OTPFields })\r\n\tpublic phoneOtpInfo?: OTPFields;\r\n\r\n\t@prop({ type: Boolean, default: false })\r\n\tpublic isPhoneVerified?: boolean;\r\n\r\n\tpublic static async updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number) {\r\n\t\treturn this.findByIdAndUpdate(userId, { $inc: { walletBalance: amount } }, { new: true });\r\n\t}\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zone.model.js","sourceRoot":"/","sources":["libraries/mongo/models/zone.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,4EAAqE;AACrE,kDAAqD;AACrD,sEAA6D;AAGtD,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,IAAI,CAAU;IAGd,IAAI,CAAU;IAGd,QAAQ,CAAgB;IAGxB,MAAM,CAAc;IAGpB,SAAS,CAAU;IAGnB,eAAe,CAAU;IAIzB,iBAAiB,CAAU;IAG3B,iBAAiB,CAAU;IAG3B,QAAQ,CAAS;IAIjB,gBAAgB,CAAU;CACjC,CAAA;AAhCY,oBAAI;AAET;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCACF;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,iCAAY,EAAE,CAAC;8BAC3B,iCAAY;sCAAC;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAU,EAAE,OAAO,EAAE,iBAAU,CAAC,MAAM,EAAE,CAAC;;oCAC1C;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uCACG;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CACS;AAIzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;+CACR;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+CACD;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;;sCACZ;AAIjB;IADN,IAAA,gBAAI,EAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;8CACJ;eA/BrB,IAAI;IADhB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;GAC5C,IAAI,CAgChB","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ZoneStatus } from '../../../utilities/enum';\nimport { ZoneGeometry } from './embedded/zone-geometry.mode';\n\n@modelOptions({ schemaOptions: { collection: 'zones' } })\nexport class Zone extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n \n\t@prop({ type: String })\n\tpublic area?: string;\n\n\t@prop({ required: true, type: ZoneGeometry })\n\tpublic geometry!: ZoneGeometry; \n\n\t@prop({ type: String, enum: ZoneStatus, default: ZoneStatus.ACTIVE })\n\tpublic status?: ZoneStatus;\n\n\t@prop({ type: String })\n\tpublic busyTitle?: string;\n\n\t@prop({ type: String })\n\tpublic busyDescription?: string; \n\n\t// Rider reward feature when he reached the target\n\t@prop({ type: Number, default: Infinity })\n\tpublic riderWeeklyTarget?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic riderWeeklyReward?: number;\n\n\t@prop({type: Number,required: true})\n\tpublic areaSqKm!: number\n\t\n // Rider reward are not be applied when isIncludedRewared false\n\t@prop({type: Boolean ,default: true})\n\tpublic isIncludedReward?: boolean \n}\n "]}
|
|
1
|
+
{"version":3,"file":"zone.model.js","sourceRoot":"/","sources":["libraries/mongo/models/zone.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA0D;AAC1D,4EAAqE;AACrE,kDAAqD;AACrD,sEAA6D;AAGtD,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,IAAI,CAAU;IAGd,IAAI,CAAU;IAGd,QAAQ,CAAgB;IAGxB,MAAM,CAAc;IAGpB,SAAS,CAAU;IAGnB,eAAe,CAAU;IAIzB,iBAAiB,CAAU;IAG3B,iBAAiB,CAAU;IAG3B,QAAQ,CAAS;IAIjB,gBAAgB,CAAU;CACjC,CAAA;AAhCY,oBAAI;AAET;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCACF;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,iCAAY,EAAE,CAAC;8BAC3B,iCAAY;sCAAC;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAU,EAAE,OAAO,EAAE,iBAAU,CAAC,MAAM,EAAE,CAAC;;oCAC1C;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uCACG;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;6CACS;AAIzB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;+CACR;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+CACD;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC;;sCACZ;AAIjB;IADN,IAAA,gBAAI,EAAC,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;;8CACJ;eA/BrB,IAAI;IADhB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;GAC5C,IAAI,CAgChB","sourcesContent":["import { modelOptions, prop } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { ZoneStatus } from '../../../utilities/enum';\r\nimport { ZoneGeometry } from './embedded/zone-geometry.mode';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'zones' } })\r\nexport class Zone extends TimeStamps {\r\n\t@prop({ required: true, type: String })\r\n\tpublic name!: string;\r\n \r\n\t@prop({ type: String })\r\n\tpublic area?: string;\r\n\r\n\t@prop({ required: true, type: ZoneGeometry })\r\n\tpublic geometry!: ZoneGeometry; \r\n\r\n\t@prop({ type: String, enum: ZoneStatus, default: ZoneStatus.ACTIVE })\r\n\tpublic status?: ZoneStatus;\r\n\r\n\t@prop({ type: String })\r\n\tpublic busyTitle?: string;\r\n\r\n\t@prop({ type: String })\r\n\tpublic busyDescription?: string; \r\n\r\n\t// Rider reward feature when he reached the target\r\n\t@prop({ type: Number, default: Infinity })\r\n\tpublic riderWeeklyTarget?: number;\r\n\r\n\t@prop({ type: Number, default: 0 })\r\n\tpublic riderWeeklyReward?: number;\r\n\r\n\t@prop({type: Number,required: true})\r\n\tpublic areaSqKm!: number\r\n\t\r\n // Rider reward are not be applied when isIncludedRewared false\r\n\t@prop({type: Boolean ,default: true})\r\n\tpublic isIncludedReward?: boolean \r\n}\r\n "]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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AAI,CAAC,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC;QAEF,MAAM,CAAC,OAAO,CAAC,cAAc,GAAG,KAAK,WAAW,IAAqB;YACpE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;YAEvC,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAEhC,IAAI,MAAM,EAAE,CAAC;gBACZ,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAQ,CAAC;YACvC,CAAC;YAED,IAAI,QAAQ,EAAE,CAAC;gBACd,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACpC,CAAC;YAED,OAAO,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5B,CAAC,CAAC;IACH,CAAC;CACD;AA3KD,gCA2KC;AAGM,MAAM,gBAAgB,GAAG,CAAC,MAAc,EAAQ,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;AAA9E,QAAA,gBAAgB,oBAA8D;AACpF,MAAM,qBAAqB,GAAG,GAAS,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;AAA/D,QAAA,qBAAqB,yBAA0C;AACrE,MAAM,qBAAqB,GAAG,CACpC,UAAkC,EAC6B,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAFzF,QAAA,qBAAqB,yBAEoE","sourcesContent":["import { Schema, Query, Model } from 'mongoose';\nimport { getModelForClass, ReturnModelType, mongoose } from '@typegoose/typegoose';\nimport { AnyParamConstructor } from '@typegoose/typegoose/lib/types';\nimport { GetByIdInputDTO } from '../../../utilities/validation';\n\n/**\n * Interface for models with soft delete capabilities\n */\nexport interface SoftDeleteModel<T> extends Model<T> {\n\tsoftDelete(_id: mongoose.Types.ObjectId): Promise<any>;\n\tsoftDeleteOne(filter: object): Promise<any>;\n\tsoftDeleteMany(filter?: object): Promise<any>;\n\tdeleteRecord(filter: object, softDelete: boolean): Promise<any>;\n\tdeleteRecords(filter: object, softDelete: boolean): Promise<any>;\n\trestore(_id: mongoose.Types.ObjectId): Promise<any>;\n\trestoreOne(filter: object): Promise<any>;\n\trestoreMany(filter?: object): Promise<any>;\n\tfindWithDeleted(filter?: object): any;\n\tfindDeleted(filter?: object): any;\n\tfindRecordById(data: GetByIdInputDTO): Promise<any>;\n}\n\n/**\n * Base class for models with soft delete functionality\n */\nexport class SoftDeleteBase {\n\tdeletedAt?: Date | null;\n}\n\n/**\n * SoftDelete class providing soft deletion functionality for mongoose models\n */\nexport class SoftDelete {\n\t/**\n\t * Apply soft delete plugin to a specific schema\n\t * @param schema Mongoose schema to enhance with soft delete functionality\n\t */\n\tpublic static applyToSchema(schema: Schema): void {\n\t\t// Add deletedAt field if it doesn't exist\n\t\tif (!schema.path('deletedAt')) {\n\t\t\tschema.add({\n\t\t\t\tdeletedAt: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\tdefault: null,\n\t\t\t\t\tindex: true,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Add schema middleware\n\t\tthis.addQueryMiddleware(schema);\n\n\t\t// Add instance methods\n\t\tthis.addInstanceMethods(schema);\n\n\t\t// Add static methods\n\t\tthis.addStaticMethods(schema);\n\t}\n\n\t/**\n\t * Apply soft delete plugin globally to all mongoose schemas\n\t */\n\tpublic static applyGlobally(): void {\n\t\tconst mongoose = require('mongoose');\n\t\tmongoose.plugin((schema: Schema) => this.applyToSchema(schema));\n\t}\n\n\t/**\n\t * Create a model with soft delete capabilities and proper TypeScript types\n\t * @param modelClass The class to create a model from\n\t * @returns A model with soft delete functionality\n\t */\n\tpublic static createModel<T extends SoftDeleteBase>(\n\t\tmodelClass: AnyParamConstructor<T>\n\t): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> {\n\t\tconst model = getModelForClass(modelClass);\n\t\treturn model as any; // The plugin adds the methods, we just need to tell TypeScript they exist\n\t}\n\n\t/**\n\t * Add query middleware to filter out soft-deleted documents\n\t * @param schema Schema to add middleware to\n\t */\n\tprivate static addQueryMiddleware(schema: Schema): void {\n\t\tconst queryMiddleware = function (this: Query<any, any>) {\n\t\t\tif (!this.getQuery().deletedAt) {\n\t\t\t\tthis.where({ deletedAt: null });\n\t\t\t}\n\t\t};\n\n\t\t// Apply middleware to relevant query methods\n\t\tschema.pre('find', queryMiddleware);\n\t\tschema.pre('findOne', queryMiddleware);\n\t\tschema.pre('findOneAndUpdate', queryMiddleware);\n\t\tschema.pre('findOneAndDelete', queryMiddleware);\n\t\tschema.pre('findOneAndReplace', queryMiddleware);\n\t\tschema.pre('updateOne', queryMiddleware);\n\t\tschema.pre('updateMany', queryMiddleware);\n\t\t// TypeScript workaround for count hook\n\t\t(schema as any).pre('count', queryMiddleware);\n\t\tschema.pre('countDocuments', queryMiddleware);\n\t\t(schema as any).pre('exists', queryMiddleware);\n\n\t\t// Override findById to respect soft delete\n\t\tschema.statics.findById = function (_id: mongoose.Types.ObjectId, projection?: any, options?: any) {\n\t\t\treturn this.findOne({ _id, deletedAt: null }, projection, options);\n\t\t};\n\t}\n\n\t/**\n\t * Add instance methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addInstanceMethods(schema: Schema): void {\n\t\tschema.methods.softDelete = function () {\n\t\t\tthis.deletedAt = new Date();\n\t\t\treturn this.save();\n\t\t};\n\n\t\tschema.methods.restore = function () {\n\t\t\tthis.deletedAt = null;\n\t\t\treturn this.save();\n\t\t};\n\t}\n\n\t/**\n\t * Add static methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addStaticMethods(schema: Schema): void {\n\t\tschema.statics.softDelete = async function (_id: mongoose.Types.ObjectId) {\n\t\t\tconst result = await this.updateOne({ _id }, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteOne = async function (filter: object) {\n\t\t\tconst result = await this.updateOne(filter, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: new Date() });\n\t\t};\n\n\t\tschema.statics.deleteRecord = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateOne({ ...filter, deletedAt: null }, { deletedAt: new Date() }).lean();\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteOne(filter).lean();\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.deleteRecords = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateMany(\n\t\t\t\t\t{ ...filter, deletedAt: null },\n\t\t\t\t\t{ deletedAt: new Date() }\n\t\t\t\t).lean();\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteMany(filter).lean();\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.restore = function (_id: mongoose.Types.ObjectId) {\n\t\t\treturn this.updateOne({ _id }, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreOne = function (filter: object) {\n\t\t\treturn this.updateOne(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.findWithDeleted = function (filter = {}) {\n\t\t\treturn this.find(filter);\n\t\t};\n\n\t\tschema.statics.findDeleted = function (filter = {}) {\n\t\t\treturn this.find({ ...filter, deletedAt: { $ne: null } });\n\t\t};\n\n\t\tschema.statics.findRecordById = async function (data: GetByIdInputDTO) {\n\t\t\tconst { _id, select, populate } = data;\n\n\t\t\tlet result = this.findById(_id);\n\n\t\t\tif (select) {\n\t\t\t\tresult = result.select(select) as any;\n\t\t\t}\n\n\t\t\tif (populate) {\n\t\t\t\tresult = result.populate(populate);\n\t\t\t}\n\n\t\t\treturn await result.exec();\n\t\t};\n\t}\n}\n\n// Export convenience functions with the same names as before for backward compatibility\nexport const softDeletePlugin = (schema: Schema): void => SoftDelete.applyToSchema(schema);\nexport const applySoftDeletePlugin = (): void => SoftDelete.applyGlobally();\nexport const createSoftDeleteModel = <T extends SoftDeleteBase>(\n\tmodelClass: AnyParamConstructor<T>\n): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> => SoftDelete.createModel(modelClass);\n"]}
|
|
1
|
+
{"version":3,"file":"soft-delete-plugin.js","sourceRoot":"/","sources":["libraries/mongo/plugins/soft-delete-plugin.ts"],"names":[],"mappings":";;;AACA,oDAAmF;AAwBnF,MAAa,cAAc;IAC1B,SAAS,CAAe;CACxB;AAFD,wCAEC;AAKD,MAAa,UAAU;IAKf,MAAM,CAAC,aAAa,CAAC,MAAc;QAEzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC;gBACV,SAAS,EAAE;oBACV,IAAI,EAAE,IAAI;oBACV,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,IAAI;iBACX;aACD,CAAC,CAAC;QACJ,CAAC;QAGD,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAGhC,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAGhC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAKM,MAAM,CAAC,aAAa;QAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACrC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAA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,GAAG,GAAS,EAAE,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC;AAA/D,QAAA,qBAAqB,yBAA0C;AACrE,MAAM,qBAAqB,GAAG,CACpC,UAAkC,EAC6B,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AAFzF,QAAA,qBAAqB,yBAEoE","sourcesContent":["import { Schema, Query, Model } from 'mongoose';\r\nimport { getModelForClass, ReturnModelType, mongoose } from '@typegoose/typegoose';\r\nimport { AnyParamConstructor } from '@typegoose/typegoose/lib/types';\r\nimport { GetByIdInputDTO } from '../../../utilities/validation';\r\n\r\n/**\r\n * Interface for models with soft delete capabilities\r\n */\r\nexport interface SoftDeleteModel<T> extends Model<T> {\r\n\tsoftDelete(_id: mongoose.Types.ObjectId): Promise<any>;\r\n\tsoftDeleteOne(filter: object): Promise<any>;\r\n\tsoftDeleteMany(filter?: object): Promise<any>;\r\n\tdeleteRecord(filter: object, softDelete: boolean): Promise<any>;\r\n\tdeleteRecords(filter: object, softDelete: boolean): Promise<any>;\r\n\trestore(_id: mongoose.Types.ObjectId): Promise<any>;\r\n\trestoreOne(filter: object): Promise<any>;\r\n\trestoreMany(filter?: object): Promise<any>;\r\n\tfindWithDeleted(filter?: object): any;\r\n\tfindDeleted(filter?: object): any;\r\n\tfindRecordById(data: GetByIdInputDTO): Promise<any>;\r\n}\r\n\r\n/**\r\n * Base class for models with soft delete functionality\r\n */\r\nexport class SoftDeleteBase {\r\n\tdeletedAt?: Date | null;\r\n}\r\n\r\n/**\r\n * SoftDelete class providing soft deletion functionality for mongoose models\r\n */\r\nexport class SoftDelete {\r\n\t/**\r\n\t * Apply soft delete plugin to a specific schema\r\n\t * @param schema Mongoose schema to enhance with soft delete functionality\r\n\t */\r\n\tpublic static applyToSchema(schema: Schema): void {\r\n\t\t// Add deletedAt field if it doesn't exist\r\n\t\tif (!schema.path('deletedAt')) {\r\n\t\t\tschema.add({\r\n\t\t\t\tdeletedAt: {\r\n\t\t\t\t\ttype: Date,\r\n\t\t\t\t\tdefault: null,\r\n\t\t\t\t\tindex: true,\r\n\t\t\t\t},\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t// Add schema middleware\r\n\t\tthis.addQueryMiddleware(schema);\r\n\r\n\t\t// Add instance methods\r\n\t\tthis.addInstanceMethods(schema);\r\n\r\n\t\t// Add static methods\r\n\t\tthis.addStaticMethods(schema);\r\n\t}\r\n\r\n\t/**\r\n\t * Apply soft delete plugin globally to all mongoose schemas\r\n\t */\r\n\tpublic static applyGlobally(): void {\r\n\t\tconst mongoose = require('mongoose');\r\n\t\tmongoose.plugin((schema: Schema) => this.applyToSchema(schema));\r\n\t}\r\n\r\n\t/**\r\n\t * Create a model with soft delete capabilities and proper TypeScript types\r\n\t * @param modelClass The class to create a model from\r\n\t * @returns A model with soft delete functionality\r\n\t */\r\n\tpublic static createModel<T extends SoftDeleteBase>(\r\n\t\tmodelClass: AnyParamConstructor<T>\r\n\t): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> {\r\n\t\tconst model = getModelForClass(modelClass);\r\n\t\treturn model as any; // The plugin adds the methods, we just need to tell TypeScript they exist\r\n\t}\r\n\r\n\t/**\r\n\t * Add query middleware to filter out soft-deleted documents\r\n\t * @param schema Schema to add middleware to\r\n\t */\r\n\tprivate static addQueryMiddleware(schema: Schema): void {\r\n\t\tconst queryMiddleware = function (this: Query<any, any>) {\r\n\t\t\tif (!this.getQuery().deletedAt) {\r\n\t\t\t\tthis.where({ deletedAt: null });\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\t// Apply middleware to relevant query methods\r\n\t\tschema.pre('find', queryMiddleware);\r\n\t\tschema.pre('findOne', queryMiddleware);\r\n\t\tschema.pre('findOneAndUpdate', queryMiddleware);\r\n\t\tschema.pre('findOneAndDelete', queryMiddleware);\r\n\t\tschema.pre('findOneAndReplace', queryMiddleware);\r\n\t\tschema.pre('updateOne', queryMiddleware);\r\n\t\tschema.pre('updateMany', queryMiddleware);\r\n\t\t// TypeScript workaround for count hook\r\n\t\t(schema as any).pre('count', queryMiddleware);\r\n\t\tschema.pre('countDocuments', queryMiddleware);\r\n\t\t(schema as any).pre('exists', queryMiddleware);\r\n\r\n\t\t// Override findById to respect soft delete\r\n\t\tschema.statics.findById = function (_id: mongoose.Types.ObjectId, projection?: any, options?: any) {\r\n\t\t\treturn this.findOne({ _id, deletedAt: null }, projection, options);\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Add instance methods for soft delete operations\r\n\t * @param schema Schema to add methods to\r\n\t */\r\n\tprivate static addInstanceMethods(schema: Schema): void {\r\n\t\tschema.methods.softDelete = function () {\r\n\t\t\tthis.deletedAt = new Date();\r\n\t\t\treturn this.save();\r\n\t\t};\r\n\r\n\t\tschema.methods.restore = function () {\r\n\t\t\tthis.deletedAt = null;\r\n\t\t\treturn this.save();\r\n\t\t};\r\n\t}\r\n\r\n\t/**\r\n\t * Add static methods for soft delete operations\r\n\t * @param schema Schema to add methods to\r\n\t */\r\n\tprivate static addStaticMethods(schema: Schema): void {\r\n\t\tschema.statics.softDelete = async function (_id: mongoose.Types.ObjectId) {\r\n\t\t\tconst result = await this.updateOne({ _id }, { deletedAt: new Date() });\r\n\t\t\treturn result.modifiedCount > 0;\r\n\t\t};\r\n\r\n\t\tschema.statics.softDeleteOne = async function (filter: object) {\r\n\t\t\tconst result = await this.updateOne(filter, { deletedAt: new Date() });\r\n\t\t\treturn result.modifiedCount > 0;\r\n\t\t};\r\n\r\n\t\tschema.statics.softDeleteMany = function (filter = {}) {\r\n\t\t\treturn this.updateMany(filter, { deletedAt: new Date() });\r\n\t\t};\r\n\r\n\t\tschema.statics.deleteRecord = async function (filter: object, softDelete: boolean) {\r\n\t\t\tif (softDelete) {\r\n\t\t\t\tconst result = await this.updateOne({ ...filter, deletedAt: null }, { deletedAt: new Date() }).lean();\r\n\t\t\t\treturn Boolean(result.modifiedCount);\r\n\t\t\t} else {\r\n\t\t\t\tconst result = await this.deleteOne(filter).lean();\r\n\t\t\t\treturn Boolean(result.deletedCount);\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tschema.statics.deleteRecords = async function (filter: object, softDelete: boolean) {\r\n\t\t\tif (softDelete) {\r\n\t\t\t\tconst result = await this.updateMany(\r\n\t\t\t\t\t{ ...filter, deletedAt: null },\r\n\t\t\t\t\t{ deletedAt: new Date() }\r\n\t\t\t\t).lean();\r\n\t\t\t\treturn Boolean(result.modifiedCount);\r\n\t\t\t} else {\r\n\t\t\t\tconst result = await this.deleteMany(filter).lean();\r\n\t\t\t\treturn Boolean(result.deletedCount);\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\tschema.statics.restore = function (_id: mongoose.Types.ObjectId) {\r\n\t\t\treturn this.updateOne({ _id }, { deletedAt: null });\r\n\t\t};\r\n\r\n\t\tschema.statics.restoreOne = function (filter: object) {\r\n\t\t\treturn this.updateOne(filter, { deletedAt: null });\r\n\t\t};\r\n\r\n\t\tschema.statics.restoreMany = function (filter = {}) {\r\n\t\t\treturn this.updateMany(filter, { deletedAt: null });\r\n\t\t};\r\n\r\n\t\tschema.statics.findWithDeleted = function (filter = {}) {\r\n\t\t\treturn this.find(filter);\r\n\t\t};\r\n\r\n\t\tschema.statics.findDeleted = function (filter = {}) {\r\n\t\t\treturn this.find({ ...filter, deletedAt: { $ne: null } });\r\n\t\t};\r\n\r\n\t\tschema.statics.findRecordById = async function (data: GetByIdInputDTO) {\r\n\t\t\tconst { _id, select, populate } = data;\r\n\r\n\t\t\tlet result = this.findById(_id);\r\n\r\n\t\t\tif (select) {\r\n\t\t\t\tresult = result.select(select) as any;\r\n\t\t\t}\r\n\r\n\t\t\tif (populate) {\r\n\t\t\t\tresult = result.populate(populate);\r\n\t\t\t}\r\n\r\n\t\t\treturn await result.exec();\r\n\t\t};\r\n\t}\r\n}\r\n\r\n// Export convenience functions with the same names as before for backward compatibility\r\nexport const softDeletePlugin = (schema: Schema): void => SoftDelete.applyToSchema(schema);\r\nexport const applySoftDeletePlugin = (): void => SoftDelete.applyGlobally();\r\nexport const createSoftDeleteModel = <T extends SoftDeleteBase>(\r\n\tmodelClass: AnyParamConstructor<T>\r\n): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> => SoftDelete.createModel(modelClass);\r\n"]}
|