@lyxa.ai/core 1.0.19 → 1.0.21
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 +4 -0
- package/dist/index.js.map +1 -1
- package/dist/libraries/mongo/models/admin-access-control.model.js +13 -2
- package/dist/libraries/mongo/models/admin-access-control.model.js.map +1 -1
- package/dist/libraries/mongo/models/attribute.model.d.ts +1 -1
- package/dist/libraries/mongo/models/attribute.model.js +3 -2
- package/dist/libraries/mongo/models/attribute.model.js.map +1 -1
- package/dist/libraries/mongo/models/card.model.d.ts +24 -0
- package/dist/libraries/mongo/models/card.model.js +109 -0
- package/dist/libraries/mongo/models/card.model.js.map +1 -0
- package/dist/libraries/mongo/models/cart-participant.model.d.ts +17 -0
- package/dist/libraries/mongo/models/cart-participant.model.js +81 -0
- package/dist/libraries/mongo/models/cart-participant.model.js.map +1 -0
- package/dist/libraries/mongo/models/cart.model.d.ts +6 -9
- package/dist/libraries/mongo/models/cart.model.js +16 -33
- package/dist/libraries/mongo/models/cart.model.js.map +1 -1
- package/dist/libraries/mongo/models/category.model.d.ts +1 -2
- package/dist/libraries/mongo/models/category.model.js +2 -7
- package/dist/libraries/mongo/models/category.model.js.map +1 -1
- package/dist/libraries/mongo/models/core-auth-identity.model.d.ts +1 -2
- package/dist/libraries/mongo/models/core-auth-identity.model.js +1 -3
- package/dist/libraries/mongo/models/core-auth-identity.model.js.map +1 -1
- package/dist/libraries/mongo/models/core-user.model.d.ts +0 -2
- package/dist/libraries/mongo/models/core-user.model.js +2 -4
- package/dist/libraries/mongo/models/core-user.model.js.map +1 -1
- package/dist/libraries/mongo/models/embedded/addon.model.d.ts +8 -0
- package/dist/libraries/mongo/models/embedded/addon.model.js +34 -0
- package/dist/libraries/mongo/models/embedded/addon.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/line-item-attribute.model.d.ts +7 -0
- package/dist/libraries/mongo/models/embedded/line-item-attribute.model.js +29 -0
- package/dist/libraries/mongo/models/embedded/line-item-attribute.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/order-cancel.model.d.ts +7 -0
- package/dist/libraries/mongo/models/embedded/order-cancel.model.js +34 -0
- package/dist/libraries/mongo/models/embedded/order-cancel.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/order-pricing.model.d.ts +18 -0
- package/dist/libraries/mongo/models/embedded/order-pricing.model.js +97 -0
- package/dist/libraries/mongo/models/embedded/order-pricing.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/payment-attempt.model.d.ts +10 -0
- package/dist/libraries/mongo/models/embedded/payment-attempt.model.js +60 -0
- package/dist/libraries/mongo/models/embedded/payment-attempt.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/payment-details.model.d.ts +9 -0
- package/dist/libraries/mongo/models/embedded/payment-details.model.js +52 -0
- package/dist/libraries/mongo/models/embedded/payment-details.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/payment-infromation.model.d.ts +7 -0
- package/dist/libraries/mongo/models/embedded/payment-infromation.model.js +43 -0
- package/dist/libraries/mongo/models/embedded/payment-infromation.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/portion.model.d.ts +5 -0
- package/dist/libraries/mongo/models/embedded/portion.model.js +32 -0
- package/dist/libraries/mongo/models/embedded/portion.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/rider-equipment.model.d.ts +4 -0
- package/dist/libraries/mongo/models/embedded/rider-equipment.model.js +27 -0
- package/dist/libraries/mongo/models/embedded/rider-equipment.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/status-timeline.model.d.ts +14 -0
- package/dist/libraries/mongo/models/embedded/status-timeline.model.js +59 -0
- package/dist/libraries/mongo/models/embedded/status-timeline.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/zone-geometry.mode.d.ts +2 -1
- package/dist/libraries/mongo/models/embedded/zone-geometry.mode.js +2 -1
- package/dist/libraries/mongo/models/embedded/zone-geometry.mode.js.map +1 -1
- package/dist/libraries/mongo/models/faq.model.d.ts +0 -1
- package/dist/libraries/mongo/models/faq.model.js +0 -5
- package/dist/libraries/mongo/models/faq.model.js.map +1 -1
- package/dist/libraries/mongo/models/index.d.ts +46 -29
- package/dist/libraries/mongo/models/index.js +48 -31
- package/dist/libraries/mongo/models/index.js.map +1 -1
- package/dist/libraries/mongo/models/line-item.model.d.ts +19 -0
- package/dist/libraries/mongo/models/line-item.model.js +84 -0
- package/dist/libraries/mongo/models/line-item.model.js.map +1 -0
- package/dist/libraries/mongo/models/order-delivery.model.d.ts +24 -0
- package/dist/libraries/mongo/models/order-delivery.model.js +119 -0
- package/dist/libraries/mongo/models/order-delivery.model.js.map +1 -0
- 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-pricing.model.d.ts +18 -0
- package/dist/libraries/mongo/models/order-pricing.model.js +88 -0
- package/dist/libraries/mongo/models/order-pricing.model.js.map +1 -0
- package/dist/libraries/mongo/models/order.model.d.ts +17 -1
- package/dist/libraries/mongo/models/order.model.js +83 -2
- package/dist/libraries/mongo/models/order.model.js.map +1 -1
- package/dist/libraries/mongo/models/product.model.js +1 -3
- package/dist/libraries/mongo/models/product.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/areeba-card.model.d.ts +14 -0
- package/dist/libraries/mongo/models/providers/areeba-card.model.js +69 -0
- package/dist/libraries/mongo/models/providers/areeba-card.model.js.map +1 -0
- package/dist/libraries/mongo/models/providers/core-apple-auth-identity.model.d.ts +0 -2
- package/dist/libraries/mongo/models/providers/core-apple-auth-identity.model.js +1 -4
- 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.d.ts +0 -2
- package/dist/libraries/mongo/models/providers/core-email-auth-identity.model.js +1 -4
- 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.d.ts +0 -2
- package/dist/libraries/mongo/models/providers/core-google-auth-identity.model.js +1 -4
- 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.d.ts +0 -2
- package/dist/libraries/mongo/models/providers/core-phone-auth-identity.model.js +1 -4
- package/dist/libraries/mongo/models/providers/core-phone-auth-identity.model.js.map +1 -1
- package/dist/libraries/mongo/models/providers/courier-order.model.d.ts +23 -0
- package/dist/libraries/mongo/models/providers/courier-order.model.js +89 -0
- package/dist/libraries/mongo/models/providers/courier-order.model.js.map +1 -0
- package/dist/libraries/mongo/models/providers/regular-order.model.d.ts +23 -0
- package/dist/libraries/mongo/models/providers/regular-order.model.js +85 -0
- package/dist/libraries/mongo/models/providers/regular-order.model.js.map +1 -0
- package/dist/libraries/mongo/models/rating-setting.model.d.ts +1 -0
- package/dist/libraries/mongo/models/rating-setting.model.js +11 -2
- package/dist/libraries/mongo/models/rating-setting.model.js.map +1 -1
- package/dist/libraries/mongo/models/request-area.model.d.ts +2 -2
- package/dist/libraries/mongo/models/request-area.model.js +2 -2
- package/dist/libraries/mongo/models/request-area.model.js.map +1 -1
- package/dist/libraries/mongo/models/rider-timeout.model.d.ts +10 -0
- package/dist/libraries/mongo/models/rider-timeout.model.js +47 -0
- package/dist/libraries/mongo/models/rider-timeout.model.js.map +1 -0
- package/dist/libraries/mongo/models/rider-tracking.model.d.ts +10 -0
- package/dist/libraries/mongo/models/rider-tracking.model.js +47 -0
- package/dist/libraries/mongo/models/rider-tracking.model.js.map +1 -0
- package/dist/libraries/mongo/models/rider.model.d.ts +50 -1
- package/dist/libraries/mongo/models/rider.model.js +238 -2
- package/dist/libraries/mongo/models/rider.model.js.map +1 -1
- package/dist/libraries/mongo/models/shared/address.model.d.ts +6 -3
- package/dist/libraries/mongo/models/shared/address.model.js +24 -13
- package/dist/libraries/mongo/models/shared/address.model.js.map +1 -1
- package/dist/libraries/mongo/models/shared/geo-location.model.d.ts +4 -0
- package/dist/libraries/mongo/models/shared/geo-location.model.js +27 -0
- package/dist/libraries/mongo/models/shared/geo-location.model.js.map +1 -0
- package/dist/libraries/mongo/models/shop-category.model.d.ts +1 -0
- package/dist/libraries/mongo/models/shop-category.model.js +7 -1
- package/dist/libraries/mongo/models/shop-category.model.js.map +1 -1
- package/dist/libraries/mongo/models/shop.model.d.ts +1 -1
- package/dist/libraries/mongo/models/shop.model.js +2 -2
- package/dist/libraries/mongo/models/shop.model.js.map +1 -1
- package/dist/libraries/mongo/models/user.model.d.ts +30 -0
- package/dist/libraries/mongo/models/user.model.js +129 -0
- package/dist/libraries/mongo/models/user.model.js.map +1 -0
- package/dist/libraries/mongo/models/zone.model.d.ts +5 -5
- package/dist/libraries/mongo/models/zone.model.js +11 -11
- package/dist/libraries/mongo/models/zone.model.js.map +1 -1
- package/dist/libraries/mongo/plugins/soft-delete-plugin.d.ts +8 -5
- package/dist/libraries/mongo/plugins/soft-delete-plugin.js +28 -0
- package/dist/libraries/mongo/plugins/soft-delete-plugin.js.map +1 -1
- package/dist/utilities/enum.d.ts +87 -9
- package/dist/utilities/enum.js +103 -9
- package/dist/utilities/enum.js.map +1 -1
- package/dist/utilities/pagination.d.ts +4 -1
- package/dist/utilities/pagination.js +44 -4
- package/dist/utilities/pagination.js.map +1 -1
- package/dist/utilities/response.js +1 -1
- package/dist/utilities/response.js.map +1 -1
- package/dist/utilities/transformers.d.ts +14 -3
- package/dist/utilities/transformers.js +37 -6
- package/dist/utilities/transformers.js.map +1 -1
- package/dist/utilities/validation/common-validation.d.ts +354 -29
- package/dist/utilities/validation/common-validation.js +39 -10
- package/dist/utilities/validation/common-validation.js.map +1 -1
- package/dist/utilities/validation/global-validation.d.ts +49 -20
- package/dist/utilities/validation/global-validation.js +6 -4
- package/dist/utilities/validation/global-validation.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ async function bootstrapCore(options) {
|
|
|
33
33
|
getLibraries().getLogger().logger.info('Successfully bootstrapped lyxa-core.');
|
|
34
34
|
const gracefulShutdown = async () => {
|
|
35
35
|
getLibraries().getLogger().logger.info('Received shutdown signal, shutting down gracefully...');
|
|
36
|
+
process.exit();
|
|
36
37
|
};
|
|
37
38
|
process.on('SIGTERM', gracefulShutdown);
|
|
38
39
|
process.on('SIGINT', gracefulShutdown);
|
|
@@ -40,6 +41,9 @@ async function bootstrapCore(options) {
|
|
|
40
41
|
getLibraries().getLogger().logger.error('Uncaught exception, shutting down...', err);
|
|
41
42
|
gracefulShutdown();
|
|
42
43
|
});
|
|
44
|
+
process.on('exit', (code) => {
|
|
45
|
+
getLibraries().getLogger().logger.info(`Exiting with code: ${code}`);
|
|
46
|
+
});
|
|
43
47
|
console.log('Created hooks.');
|
|
44
48
|
}
|
|
45
49
|
catch (e) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;AAoBA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";;;;;;AAoBA,sCAyBC;AAED,8CAyDC;AAED,oCAEC;AA5GD,2CAA6C;AAC7C,mCAAmC;AACnC,wDAAgC;AAChC,6DAAuF;AACvF,+GAA4G;AAC5G,+CAAgD;AAChD,6CAAiD;AACjD,6CAAyD;AACzD,iDAA2D;AAC3D,uDAAgE;AAChE,+CAAmD;AACnD,mDAAuD;AACvD,6CAAmE;AACnE,0FAAuF;AAIvF,6GAA4G;AAAnG,4IAAA,4BAA4B,OAAA;AACrC,2CAA4G;AAAnG,6GAAA,oBAAoB,OAAA;AAAE,0GAAA,iBAAiB,OAAA;AAAE,uHAAA,8BAA8B,OAAA;AAEzE,KAAK,UAAU,aAAa,CAAC,OAA8B;IACjE,IAAI,CAAC;QACJ,MAAM,iBAAiB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C,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAEtC,MAAM,IAAA,oBAAY,EAAC,kFAAkF,CAAC,CAAC;IACvG,MAAM,gBAAgB,GAAG,2CAAoB,CAAC,mBAAmB,EAAE,CAAC;IAEpE,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAiB,CAAC;IAEtD,KAAK,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,gBAAgB,EAAE,CAAC;QAC3E,IAAI,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,QAAQ,GAAG,kBAAS,CAAC,GAAG,CAAC,iBAAwB,CAAC,CAAC;YACnD,oBAAoB,CAAC,GAAG,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,IAAA,wBAAgB,EAAC,OAAO,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;YAC/C,OAAO,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACJ,CAAC;AACF,CAAC;AAED,SAAgB,YAAY;IAC3B,OAAO,kBAAS,CAAC,GAAG,CAAC,0BAAc,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import { LibraryManager } from './libraries';\r\nimport { Container } from 'typedi';\r\nimport mongoose from 'mongoose';\r\nimport { ConfigurationOptions, ConfigurationService } from './libraries/configuration';\r\nimport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\r\nimport { LyxaLogger } from './libraries/logger';\r\nimport { RedisService } from './libraries/redis';\r\nimport { initGlobalConnection } from './libraries/mongo';\r\nimport { SecretManagerService } from './libraries/secrets';\r\nimport { MicroServiceDispatcher } from './libraries/dispatcher';\r\nimport { TwilioService } from './libraries/twilio';\r\nimport { FirebaseService } from './libraries/firebase';\r\nimport { initEventBus, subscribeToEvent } from './libraries/event';\r\nimport { SubscriptionRegistry } from './libraries/event/registry/SubscriptionRegistry';\r\nimport { AuthEntityType, signTokenPair } from './libraries/auth';\r\n\r\nexport { ConfigurationOptions } from './libraries/configuration';\r\nexport { EnvironmentConfigurationType } from './libraries/configuration/types/EnvironmentConfigurationType';\r\nexport { initGlobalConnection, createGlobalModel, createGlobalDiscriminatorModel } from './libraries/mongo';\r\n\r\nexport async function bootstrapCore(options?: ConfigurationOptions) {\r\n\ttry {\r\n\t\tawait registerLibraries(options);\r\n\r\n\t\tgetLibraries().getLogger().logger.info('Successfully bootstrapped lyxa-core.');\r\n\r\n\t\tconst gracefulShutdown = async () => {\r\n\t\t\tgetLibraries().getLogger().logger.info('Received shutdown signal, shutting down gracefully...');\r\n\t\t\tprocess.exit()\r\n\t\t};\r\n\r\n\t\tprocess.on('SIGTERM', gracefulShutdown);\r\n\t\tprocess.on('SIGINT', gracefulShutdown);\r\n\t\tprocess.on('uncaughtException', err => {\r\n\t\t\tgetLibraries().getLogger().logger.error('Uncaught exception, shutting down...', err);\r\n\t\t\tgracefulShutdown();\r\n\t\t});\r\n\t\tprocess.on('exit', (code) => {\r\n\t\t\tgetLibraries().getLogger().logger.info(`Exiting with code: ${code}`);\r\n\t\t});\r\n\r\n\t\tconsole.log('Created hooks.');\r\n\t} catch (e) {\r\n\t\tconsole.error(e);\r\n\t}\r\n}\r\n\r\nexport async function registerLibraries(options?: ConfigurationOptions) {\r\n\t// Setup configuration.\r\n\tconst configurationInstance = new ConfigurationService(options);\r\n\tContainer.set(ConfigurationService, configurationInstance);\r\n\r\n\t// Setup redis.\r\n\tconst redisInstance = new RedisService(configurationInstance.options.redisURL!);\r\n\tContainer.set(RedisService, redisInstance);\r\n\r\n\t// Setup secret\r\n\tconst secretInstance = new SecretManagerService(configurationInstance, redisInstance);\r\n\tContainer.set(SecretManagerService, secretInstance);\r\n\r\n\tconst mongoUrl = await getLibraries().getSecretsService().getKey('MONGO_URL');\r\n\r\n\tawait mongoose.connect(mongoUrl!, { dbName: `lyxa-${options!.environment}-${options!.tenet}` });\r\n\tmongoose.set(\r\n\t\t'debug',\r\n\t\tgetLibraries().getConfigurationService().options.environment == EnvironmentConfigurationType.DEV\r\n\t);\r\n\r\n\tawait initGlobalConnection(mongoUrl!, options!.environment);\r\n\r\n\t// Setup logger\r\n\tconst loggerInstance = new LyxaLogger(options!.instanceType!, mongoUrl!);\r\n\tContainer.set(LyxaLogger, loggerInstance);\r\n\r\n\t// Setup firebase\r\n\tconst firebaseInstance = new FirebaseService(configurationInstance!);\r\n\tContainer.set(FirebaseService, firebaseInstance);\r\n\r\n\t// Setup microservice dispatcher\r\n\tconst microserviceDispatcherInstance = new MicroServiceDispatcher(secretInstance);\r\n\tContainer.set(MicroServiceDispatcher, microserviceDispatcherInstance);\r\n\r\n\t// Setup twilio\r\n\tconst twilioServiceInstance = new TwilioService();\r\n\tContainer.set(TwilioService, twilioServiceInstance);\r\n\r\n\tconsole.log('Initialized everything');\r\n\r\n\tawait initEventBus('amqps://vgyuplrd:wto6vUYnb4zeBI5lntKT4gj7rT8n1vwg@dog.lmq.cloudamqp.com/vgyuplrd');\r\n\tconst allSubscriptions = SubscriptionRegistry.getAllSubscriptions();\r\n\r\n\tconst instantiatedServices = new Map<Function, any>();\r\n\r\n\tfor (const { eventId, targetConstructor, methodName } of allSubscriptions) {\r\n\t\tlet instance = instantiatedServices.get(targetConstructor);\r\n\t\tif (!instance) {\r\n\t\t\tinstance = Container.get(targetConstructor as any);\r\n\t\t\tinstantiatedServices.set(targetConstructor, instance);\r\n\t\t}\r\n\r\n\t\tawait subscribeToEvent(eventId, async payload => {\r\n\t\t\treturn instance[methodName](payload);\r\n\t\t});\r\n\t}\r\n}\r\n\r\nexport function getLibraries(): LibraryManager {\r\n\treturn Container.get(LibraryManager);\r\n}\r\n"]}
|
|
@@ -18,6 +18,10 @@ const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
|
18
18
|
const bcryptjs_1 = __importDefault(require("bcryptjs"));
|
|
19
19
|
const enum_1 = require("../../../utilities/enum");
|
|
20
20
|
const admin_model_1 = require("./admin.model");
|
|
21
|
+
async function hashPassword(password) {
|
|
22
|
+
const salt = await bcryptjs_1.default.genSalt(10);
|
|
23
|
+
return bcryptjs_1.default.hash(password, salt);
|
|
24
|
+
}
|
|
21
25
|
let AdminAccessControl = class AdminAccessControl extends defaultClasses_1.TimeStamps {
|
|
22
26
|
email;
|
|
23
27
|
password;
|
|
@@ -44,8 +48,15 @@ __decorate([
|
|
|
44
48
|
exports.AdminAccessControl = AdminAccessControl = __decorate([
|
|
45
49
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
46
50
|
if (this.isModified('password')) {
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
this.password = await hashPassword(this.password);
|
|
52
|
+
}
|
|
53
|
+
next();
|
|
54
|
+
}),
|
|
55
|
+
(0, typegoose_1.pre)('findOneAndUpdate', async function (next) {
|
|
56
|
+
const update = this.getUpdate();
|
|
57
|
+
if (update?.password) {
|
|
58
|
+
update.password = await hashPassword(update.password);
|
|
59
|
+
this.setUpdate(update);
|
|
49
60
|
}
|
|
50
61
|
next();
|
|
51
62
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-access-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/admin-access-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,4EAAqE;AACrE,wDAA8B;AAC9B,kDAAoD;AACpD,+CAAsC;
|
|
1
|
+
{"version":3,"file":"admin-access-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/admin-access-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAoE;AACpE,4EAAqE;AACrE,wDAA8B;AAC9B,kDAAoD;AACpD,+CAAsC;AAGtC,KAAK,UAAU,YAAY,CAAC,QAAgB;IAC3C,MAAM,IAAI,GAAG,MAAM,kBAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;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AC,SAAS,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;QACD,IAAI,EAAE,CAAC;IACN,CAAC,CAAC;IAEH,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,qBAAqB,EAAE,EAAE,CAAC;GAC1D,kBAAkB,CAY9B","sourcesContent":["import { modelOptions, prop, pre, Ref } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport bcrypt from 'bcryptjs';\r\nimport { AdminRole } from '../../../utilities/enum';\r\nimport { Admin } from './admin.model';\r\nimport { Query } from 'mongoose';\r\n\r\nasync function hashPassword(password: string): Promise<string> {\r\n\tconst salt = await bcrypt.genSalt(10);\r\n\treturn bcrypt.hash(password, salt);\r\n}\r\n\r\n@pre<AdminAccessControl>('save', async function (next) {\r\n\tif (this.isModified('password')) {\r\n\t\tthis.password = await hashPassword(this.password);\r\n\t}\r\n\tnext();\r\n})\r\n\r\n@pre<Query<any, AdminAccessControl>>('findOneAndUpdate', async function(next) {\r\n\tconst update = this.getUpdate() as Record<string, any>;\r\n\tif (update?.password) {\r\n\t update.password = await hashPassword(update.password);\r\n\t this.setUpdate(update);\r\n\t}\r\n\tnext();\r\n })\r\n\r\n@modelOptions({ schemaOptions: { collection: 'adminAccessControls' } })\r\nexport class AdminAccessControl extends TimeStamps {\r\n\t@prop({ required: true, type: String, unique: true })\r\n\tpublic email!: string;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic password!: string;\r\n\r\n\t@prop({ required: true, ref: () => Admin })\r\n\tpublic admin!: Ref<Admin>;\r\n\r\n\t@prop({ required: true, type: String, enum: AdminRole })\r\n\tpublic role!: AdminRole;\r\n}\r\n"]}
|
|
@@ -55,10 +55,11 @@ __decorate([
|
|
|
55
55
|
__metadata("design:type", Number)
|
|
56
56
|
], Attribute.prototype, "maximumRequiredItems", void 0);
|
|
57
57
|
__decorate([
|
|
58
|
-
(0, typegoose_1.prop)({ type: [attribute_item_model_1.AttributeItem]
|
|
58
|
+
(0, typegoose_1.prop)({ required: true, type: [attribute_item_model_1.AttributeItem] }),
|
|
59
59
|
__metadata("design:type", Array)
|
|
60
60
|
], Attribute.prototype, "items", void 0);
|
|
61
61
|
exports.Attribute = Attribute = __decorate([
|
|
62
|
-
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'attributes' } })
|
|
62
|
+
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'attributes' } }),
|
|
63
|
+
(0, typegoose_1.Index)({ shop: 1, name: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })
|
|
63
64
|
], Attribute);
|
|
64
65
|
//# sourceMappingURL=attribute.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribute.model.js","sourceRoot":"/","sources":["libraries/mongo/models/attribute.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"attribute.model.js","sourceRoot":"/","sources":["libraries/mongo/models/attribute.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,4EAAqE;AACrE,0EAAgE;AAChE,kDAAqE;AACrE,6CAAoC;AAI7B,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,2BAAU;IAEjC,IAAI,CAAa;IAGjB,IAAI,CAAU;IAGd,UAAU,CAAW;IAQrB,aAAa,CAA8B;IAG3C,oBAAoB,CAAU;IAG9B,oBAAoB,CAAU;IAG9B,KAAK,CAAmB;CAC/B,CAAA;AA1BY,8BAAS;AAEd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;uCAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;6CACZ;AAQrB;IANN,IAAA,gBAAI,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,iCAA0B;QAChC,OAAO,EAAE,iCAA0B,CAAC,MAAM;KAC1C,CAAC;;gDACgD;AAG3C;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACN;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACN;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,oCAAa,CAAC,EAAE,CAAC;;wCACjB;oBAzBnB,SAAS;IAFrB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,CAAC;IAC7D,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;GAC/E,SAAS,CA0BrB","sourcesContent":["import { Index, modelOptions, prop, Ref } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { AttributeItem } from './embedded/attribute-item.model';\r\nimport { AttributeItemSelectionType } from '../../../utilities/enum';\r\nimport { Shop } from './shop.model';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'attributes' } })\r\n@Index({ shop: 1, name: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\r\nexport class Attribute extends TimeStamps {\r\n\t@prop({ required: true, ref: () => Shop })\r\n\tpublic shop!: Ref<Shop>;\r\n\r\n\t@prop({ required: true, type: String })\r\n\tpublic name!: string;\r\n\r\n\t@prop({ type: Boolean, default: false })\r\n\tpublic isRequired?: boolean;\r\n\r\n\t@prop({\r\n\t\trequired: true,\r\n\t\ttype: String,\r\n\t\tenum: AttributeItemSelectionType,\r\n\t\tdefault: AttributeItemSelectionType.SINGLE,\r\n\t})\r\n\tpublic selectionType!: AttributeItemSelectionType;\r\n\r\n\t@prop({ type: Number, min: 0, default: 0 })\r\n\tpublic minimumRequiredItems?: number;\r\n\r\n\t@prop({ type: Number, min: 0, default: 0 })\r\n\tpublic maximumRequiredItems?: number;\r\n\r\n\t@prop({ required: true, type: [AttributeItem] })\r\n\tpublic items!: AttributeItem[];\r\n}\r\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Ref } from '@typegoose/typegoose';
|
|
2
|
+
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
|
+
import { CoreUser } from './core-user.model';
|
|
4
|
+
import { Parent } from './parent.model';
|
|
5
|
+
import { CardType, CardUserType } from '../../../utilities/enum';
|
|
6
|
+
export declare class Card extends TimeStamps {
|
|
7
|
+
cardType: CardType;
|
|
8
|
+
coreUser?: Ref<CoreUser>;
|
|
9
|
+
parent?: Ref<Parent>;
|
|
10
|
+
userType?: CardUserType;
|
|
11
|
+
nameOfCard?: string;
|
|
12
|
+
card_number: string;
|
|
13
|
+
cvv: string;
|
|
14
|
+
expiry_month: string;
|
|
15
|
+
expiry_year: string;
|
|
16
|
+
expiryDateString?: string;
|
|
17
|
+
expiryDate?: Date;
|
|
18
|
+
currency?: string;
|
|
19
|
+
defaultCard?: boolean;
|
|
20
|
+
cardTypeString?: string;
|
|
21
|
+
security?: string;
|
|
22
|
+
pins?: string[];
|
|
23
|
+
mode?: string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Card = void 0;
|
|
13
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
+
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
|
+
const core_user_model_1 = require("./core-user.model");
|
|
16
|
+
const parent_model_1 = require("./parent.model");
|
|
17
|
+
const enum_1 = require("../../../utilities/enum");
|
|
18
|
+
let Card = class Card extends defaultClasses_1.TimeStamps {
|
|
19
|
+
cardType;
|
|
20
|
+
coreUser;
|
|
21
|
+
parent;
|
|
22
|
+
userType;
|
|
23
|
+
nameOfCard;
|
|
24
|
+
card_number;
|
|
25
|
+
cvv;
|
|
26
|
+
expiry_month;
|
|
27
|
+
expiry_year;
|
|
28
|
+
expiryDateString;
|
|
29
|
+
expiryDate;
|
|
30
|
+
currency;
|
|
31
|
+
defaultCard;
|
|
32
|
+
cardTypeString;
|
|
33
|
+
security;
|
|
34
|
+
pins;
|
|
35
|
+
mode;
|
|
36
|
+
};
|
|
37
|
+
exports.Card = Card;
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typegoose_1.prop)({ type: String, enum: enum_1.CardType }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], Card.prototype, "cardType", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typegoose_1.prop)({ ref: () => core_user_model_1.CoreUser }),
|
|
44
|
+
__metadata("design:type", Object)
|
|
45
|
+
], Card.prototype, "coreUser", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typegoose_1.prop)({ ref: () => parent_model_1.Parent }),
|
|
48
|
+
__metadata("design:type", Object)
|
|
49
|
+
], Card.prototype, "parent", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typegoose_1.prop)({ type: String, enum: enum_1.CardUserType }),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], Card.prototype, "userType", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typegoose_1.prop)({ type: String }),
|
|
56
|
+
__metadata("design:type", String)
|
|
57
|
+
], Card.prototype, "nameOfCard", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typegoose_1.prop)({ type: String, required: true }),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], Card.prototype, "card_number", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typegoose_1.prop)({ type: String, required: true }),
|
|
64
|
+
__metadata("design:type", String)
|
|
65
|
+
], Card.prototype, "cvv", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typegoose_1.prop)({ type: String, required: true }),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], Card.prototype, "expiry_month", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, typegoose_1.prop)({ type: String, required: true }),
|
|
72
|
+
__metadata("design:type", String)
|
|
73
|
+
], Card.prototype, "expiry_year", void 0);
|
|
74
|
+
__decorate([
|
|
75
|
+
(0, typegoose_1.prop)({ type: String }),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], Card.prototype, "expiryDateString", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, typegoose_1.prop)({ type: Date }),
|
|
80
|
+
__metadata("design:type", Date)
|
|
81
|
+
], Card.prototype, "expiryDate", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, typegoose_1.prop)({ type: String, required: true, default: 'NGN' }),
|
|
84
|
+
__metadata("design:type", String)
|
|
85
|
+
], Card.prototype, "currency", void 0);
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
88
|
+
__metadata("design:type", Boolean)
|
|
89
|
+
], Card.prototype, "defaultCard", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, typegoose_1.prop)({ type: String }),
|
|
92
|
+
__metadata("design:type", String)
|
|
93
|
+
], Card.prototype, "cardTypeString", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, typegoose_1.prop)({ type: String }),
|
|
96
|
+
__metadata("design:type", String)
|
|
97
|
+
], Card.prototype, "security", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, typegoose_1.prop)({ type: () => [String] }),
|
|
100
|
+
__metadata("design:type", Array)
|
|
101
|
+
], Card.prototype, "pins", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, typegoose_1.prop)({ type: String }),
|
|
104
|
+
__metadata("design:type", String)
|
|
105
|
+
], Card.prototype, "mode", void 0);
|
|
106
|
+
exports.Card = Card = __decorate([
|
|
107
|
+
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'cards', timestamps: true, discriminatorKey: 'cardType' } })
|
|
108
|
+
], Card);
|
|
109
|
+
//# sourceMappingURL=card.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card.model.js","sourceRoot":"/","sources":["libraries/mongo/models/card.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,4EAAqE;AACrE,uDAA6C;AAC7C,iDAAwC;AACxC,kDAAiE;AAG1D,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,QAAQ,CAAW;IAGnB,QAAQ,CAAiB;IAGzB,MAAM,CAAe;IAGrB,QAAQ,CAAg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IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;8BACD,IAAI;wCAAC;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;sCAC9B;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;yCACX;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACQ;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sCACE;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;;kCACR;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCACF;eAlDT,IAAI;IADhB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,EAAE,CAAC;GAC5F,IAAI,CAmDhB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { CoreUser } from './core-user.model';\r\nimport { Parent } from './parent.model';\r\nimport { CardType, CardUserType } from '../../../utilities/enum';\r\n\r\n@modelOptions({ schemaOptions: { collection: 'cards', timestamps: true, discriminatorKey: 'cardType' } })\r\nexport class Card extends TimeStamps {\r\n\t@prop({ type: String, enum: CardType })\r\n\tpublic cardType: CardType;\r\n\r\n\t@prop({ ref: () => CoreUser })\r\n\tpublic coreUser?: Ref<CoreUser>;\r\n\r\n\t@prop({ ref: () => Parent })\r\n\tpublic parent?: Ref<Parent>;\r\n\r\n\t@prop({ type: String, enum: CardUserType })\r\n\tpublic userType?: CardUserType;\r\n\r\n\t@prop({ type: String })\r\n\tpublic nameOfCard?: string;\r\n\r\n\t@prop({ type: String, required: true })\r\n\tpublic card_number!: string;\r\n\r\n\t@prop({ type: String, required: true })\r\n\tpublic cvv!: string;\r\n\r\n\t@prop({ type: String, required: true })\r\n\tpublic expiry_month!: string;\r\n\r\n\t@prop({ type: String, required: true })\r\n\tpublic expiry_year!: string;\r\n\r\n\t@prop({ type: String })\r\n\tpublic expiryDateString?: string;\r\n\r\n\t@prop({ type: Date })\r\n\tpublic expiryDate?: Date;\r\n\r\n\t@prop({ type: String, required: true, default: 'NGN' })\r\n\tpublic currency?: string;\r\n\r\n\t@prop({ type: Boolean, default: false })\r\n\tpublic defaultCard?: boolean;\r\n\r\n\t@prop({ type: String })\r\n\tpublic cardTypeString?: string;\r\n\r\n\t@prop({ type: String })\r\n\tpublic security?: string;\r\n\r\n\t@prop({ type: () => [String] })\r\n\tpublic pins?: string[];\r\n\r\n\t@prop({ type: String })\r\n\tpublic mode?: string;\r\n}\r\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Ref } from '@typegoose/typegoose';
|
|
2
|
+
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
3
|
+
import { Cart } from './cart.model';
|
|
4
|
+
import { PaymentMethod } from '../../../utilities/enum';
|
|
5
|
+
import { PaymentInformation } from './embedded/payment-infromation.model';
|
|
6
|
+
import { User } from './user.model';
|
|
7
|
+
export declare class CartParticipant extends TimeStamps {
|
|
8
|
+
cart: Ref<Cart>;
|
|
9
|
+
user: Ref<User>;
|
|
10
|
+
joinedAt: Date;
|
|
11
|
+
isReady: boolean;
|
|
12
|
+
isPaid: boolean;
|
|
13
|
+
readyAt?: Date;
|
|
14
|
+
spentAmount: number;
|
|
15
|
+
paymentMethod?: PaymentMethod;
|
|
16
|
+
paymentInformation?: PaymentInformation;
|
|
17
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CartParticipant = void 0;
|
|
13
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
+
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
15
|
+
const cart_model_1 = require("./cart.model");
|
|
16
|
+
const enum_1 = require("../../../utilities/enum");
|
|
17
|
+
const payment_infromation_model_1 = require("./embedded/payment-infromation.model");
|
|
18
|
+
const user_model_1 = require("./user.model");
|
|
19
|
+
let CartParticipant = class CartParticipant extends defaultClasses_1.TimeStamps {
|
|
20
|
+
cart;
|
|
21
|
+
user;
|
|
22
|
+
joinedAt;
|
|
23
|
+
isReady;
|
|
24
|
+
isPaid;
|
|
25
|
+
readyAt;
|
|
26
|
+
spentAmount;
|
|
27
|
+
paymentMethod;
|
|
28
|
+
paymentInformation;
|
|
29
|
+
};
|
|
30
|
+
exports.CartParticipant = CartParticipant;
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, typegoose_1.prop)({ required: true, ref: () => cart_model_1.Cart }),
|
|
33
|
+
__metadata("design:type", Object)
|
|
34
|
+
], CartParticipant.prototype, "cart", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typegoose_1.prop)({ required: true, ref: () => user_model_1.User }),
|
|
37
|
+
__metadata("design:type", Object)
|
|
38
|
+
], CartParticipant.prototype, "user", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typegoose_1.prop)({ default: () => new Date() }),
|
|
41
|
+
__metadata("design:type", Date)
|
|
42
|
+
], CartParticipant.prototype, "joinedAt", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typegoose_1.prop)({ default: false }),
|
|
45
|
+
__metadata("design:type", Boolean)
|
|
46
|
+
], CartParticipant.prototype, "isReady", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typegoose_1.prop)({ default: false }),
|
|
49
|
+
__metadata("design:type", Boolean)
|
|
50
|
+
], CartParticipant.prototype, "isPaid", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, typegoose_1.prop)(),
|
|
53
|
+
__metadata("design:type", Date)
|
|
54
|
+
], CartParticipant.prototype, "readyAt", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, typegoose_1.prop)({ default: 0 }),
|
|
57
|
+
__metadata("design:type", Number)
|
|
58
|
+
], CartParticipant.prototype, "spentAmount", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, typegoose_1.prop)({ enum: enum_1.PaymentMethod, type: String }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], CartParticipant.prototype, "paymentMethod", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
(0, typegoose_1.prop)({ type: () => payment_infromation_model_1.PaymentInformation }),
|
|
65
|
+
__metadata("design:type", payment_infromation_model_1.PaymentInformation)
|
|
66
|
+
], CartParticipant.prototype, "paymentInformation", void 0);
|
|
67
|
+
exports.CartParticipant = CartParticipant = __decorate([
|
|
68
|
+
(0, typegoose_1.modelOptions)({
|
|
69
|
+
schemaOptions: {
|
|
70
|
+
collection: 'cartParticipants',
|
|
71
|
+
toJSON: { virtuals: true },
|
|
72
|
+
toObject: { virtuals: true },
|
|
73
|
+
},
|
|
74
|
+
options: {
|
|
75
|
+
allowMixed: typegoose_1.Severity.ALLOW,
|
|
76
|
+
},
|
|
77
|
+
}),
|
|
78
|
+
(0, typegoose_1.index)({ cart: 1, user: 1 }, { unique: true }),
|
|
79
|
+
(0, typegoose_1.index)({ cart: 1 })
|
|
80
|
+
], CartParticipant);
|
|
81
|
+
//# sourceMappingURL=cart-participant.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cart-participant.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cart-participant.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAgF;AAChF,4EAAqE;AACrE,6CAAoC;AACpC,kDAAwD;AACxD,oFAA0E;AAC1E,6CAAoC;AAiB7B,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,2BAAU;IAEvC,IAAI,CAAa;IAGjB,IAAI,CAAa;IAGjB,QAAQ,CAAQ;IAGhB,OAAO,CAAW;IAGlB,MAAM,CAAW;IAGjB,OAAO,CAAQ;IAGf,WAAW,CAAU;IAGrB,aAAa,CAAiB;IAG9B,kBAAkB,CAAsB;CAC/C,CAAA;AA3BY,0CAAe;AAEpB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;6CAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;6CAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;8BAClB,IAAI;iDAAC;AAGhB;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;gDACA;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;+CACD;AAGjB;IADN,IAAA,gBAAI,GAAE;8BACU,IAAI;gDAAC;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;oDACO;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,oBAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sDACP;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,8CAAkB,EAAE,CAAC;8BACb,8CAAkB;2DAAC;0BA1BnC,eAAe;IAZ3B,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE;YACd,UAAU,EAAE,kBAAkB;YAC9B,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC1B,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC5B;QACD,OAAO,EAAE;YACR,UAAU,EAAE,oBAAQ,CAAC,KAAK;SAC1B;KACD,CAAC;IACD,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC7C,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;GACN,eAAe,CA2B3B","sourcesContent":["import { prop, Ref, index, modelOptions, Severity } from '@typegoose/typegoose';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { Cart } from './cart.model';\r\nimport { PaymentMethod } from '../../../utilities/enum';\r\nimport { PaymentInformation } from './embedded/payment-infromation.model';\r\nimport { User } from './user.model';\r\n\r\n/**\r\n * CartParticipant model - Tracks users participating in a group cart\r\n */\r\n@modelOptions({\r\n\tschemaOptions: {\r\n\t\tcollection: 'cartParticipants',\r\n\t\ttoJSON: { virtuals: true },\r\n\t\ttoObject: { virtuals: true },\r\n\t},\r\n\toptions: {\r\n\t\tallowMixed: Severity.ALLOW,\r\n\t},\r\n})\r\n@index({ cart: 1, user: 1 }, { unique: true })\r\n@index({ cart: 1 })\r\nexport class CartParticipant extends TimeStamps {\r\n\t@prop({ required: true, ref: () => Cart })\r\n\tpublic cart!: Ref<Cart>;\r\n\r\n\t@prop({ required: true, ref: () => User })\r\n\tpublic user!: Ref<User>;\r\n\r\n\t@prop({ default: () => new Date() })\r\n\tpublic joinedAt!: Date;\r\n\r\n\t@prop({ default: false })\r\n\tpublic isReady!: boolean;\r\n\r\n\t@prop({ default: false })\r\n\tpublic isPaid!: boolean;\r\n\r\n\t@prop()\r\n\tpublic readyAt?: Date;\r\n\r\n\t@prop({ default: 0 })\r\n\tpublic spentAmount!: number;\r\n\r\n\t@prop({ enum: PaymentMethod, type: String })\r\n\tpublic paymentMethod?: PaymentMethod;\r\n\r\n\t@prop({ type: () => PaymentInformation })\r\n\tpublic paymentInformation?: PaymentInformation;\r\n}\r\n"]}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { Ref
|
|
2
|
-
import { CoreUser } from './core-user.model';
|
|
1
|
+
import { Ref } from '@typegoose/typegoose';
|
|
3
2
|
import { Shop } from './shop.model';
|
|
4
3
|
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
5
|
-
import { CartStatus,
|
|
4
|
+
import { CartStatus, PaymentPreference } from '../../../utilities/enum';
|
|
6
5
|
import { UserAddress } from './shared/address.model';
|
|
7
6
|
import { Coupon } from './coupon.model';
|
|
7
|
+
import { User } from './user.model';
|
|
8
8
|
export declare class Cart extends TimeStamps {
|
|
9
9
|
title?: string;
|
|
10
|
-
slug
|
|
11
|
-
user: Ref<
|
|
10
|
+
slug?: string;
|
|
11
|
+
user: Ref<User>;
|
|
12
12
|
shop: Ref<Shop>;
|
|
13
13
|
deliveryAddress?: UserAddress;
|
|
14
14
|
isGroupOrder?: boolean;
|
|
15
15
|
deadlineToOrder?: Date;
|
|
16
|
-
paymentPreference?:
|
|
16
|
+
paymentPreference?: PaymentPreference;
|
|
17
17
|
spendingLimitForGuest?: number;
|
|
18
18
|
status: CartStatus;
|
|
19
19
|
coupon?: Ref<Coupon>;
|
|
20
|
-
discountValueType?: ValueType;
|
|
21
|
-
discountValue: number;
|
|
22
20
|
}
|
|
23
|
-
export declare const CartModel: ReturnModelType<typeof Cart>;
|
|
@@ -12,16 +12,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.Cart = void 0;
|
|
16
16
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
17
|
-
const core_user_model_1 = require("./core-user.model");
|
|
18
17
|
const shop_model_1 = require("./shop.model");
|
|
19
18
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
20
19
|
const enum_1 = require("../../../utilities/enum");
|
|
21
20
|
const address_model_1 = require("./shared/address.model");
|
|
22
21
|
const slugify_1 = __importDefault(require("slugify"));
|
|
23
|
-
const
|
|
22
|
+
const crypto_1 = require("crypto");
|
|
24
23
|
const coupon_model_1 = require("./coupon.model");
|
|
24
|
+
const user_model_1 = require("./user.model");
|
|
25
25
|
let Cart = class Cart extends defaultClasses_1.TimeStamps {
|
|
26
26
|
title;
|
|
27
27
|
slug;
|
|
@@ -34,12 +34,10 @@ let Cart = class Cart extends defaultClasses_1.TimeStamps {
|
|
|
34
34
|
spendingLimitForGuest;
|
|
35
35
|
status;
|
|
36
36
|
coupon;
|
|
37
|
-
discountValueType;
|
|
38
|
-
discountValue;
|
|
39
37
|
};
|
|
40
38
|
exports.Cart = Cart;
|
|
41
39
|
__decorate([
|
|
42
|
-
(0, typegoose_1.prop)({
|
|
40
|
+
(0, typegoose_1.prop)({ trim: true, maxlength: 100 }),
|
|
43
41
|
__metadata("design:type", String)
|
|
44
42
|
], Cart.prototype, "title", void 0);
|
|
45
43
|
__decorate([
|
|
@@ -47,7 +45,7 @@ __decorate([
|
|
|
47
45
|
__metadata("design:type", String)
|
|
48
46
|
], Cart.prototype, "slug", void 0);
|
|
49
47
|
__decorate([
|
|
50
|
-
(0, typegoose_1.prop)({ required: true, ref: () =>
|
|
48
|
+
(0, typegoose_1.prop)({ required: true, ref: () => user_model_1.User }),
|
|
51
49
|
__metadata("design:type", Object)
|
|
52
50
|
], Cart.prototype, "user", void 0);
|
|
53
51
|
__decorate([
|
|
@@ -59,19 +57,19 @@ __decorate([
|
|
|
59
57
|
__metadata("design:type", address_model_1.UserAddress)
|
|
60
58
|
], Cart.prototype, "deliveryAddress", void 0);
|
|
61
59
|
__decorate([
|
|
62
|
-
(0, typegoose_1.prop)({ default: false }),
|
|
60
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
63
61
|
__metadata("design:type", Boolean)
|
|
64
62
|
], Cart.prototype, "isGroupOrder", void 0);
|
|
65
63
|
__decorate([
|
|
66
|
-
(0, typegoose_1.prop)(),
|
|
64
|
+
(0, typegoose_1.prop)({ type: Date }),
|
|
67
65
|
__metadata("design:type", Date)
|
|
68
66
|
], Cart.prototype, "deadlineToOrder", void 0);
|
|
69
67
|
__decorate([
|
|
70
|
-
(0, typegoose_1.prop)({ enum: enum_1.PaymentPreference
|
|
68
|
+
(0, typegoose_1.prop)({ type: String, enum: enum_1.PaymentPreference }),
|
|
71
69
|
__metadata("design:type", String)
|
|
72
70
|
], Cart.prototype, "paymentPreference", void 0);
|
|
73
71
|
__decorate([
|
|
74
|
-
(0, typegoose_1.prop)({
|
|
72
|
+
(0, typegoose_1.prop)({ type: Number, default: Infinity }),
|
|
75
73
|
__metadata("design:type", Number)
|
|
76
74
|
], Cart.prototype, "spendingLimitForGuest", void 0);
|
|
77
75
|
__decorate([
|
|
@@ -87,14 +85,6 @@ __decorate([
|
|
|
87
85
|
(0, typegoose_1.prop)({ ref: () => coupon_model_1.Coupon }),
|
|
88
86
|
__metadata("design:type", Object)
|
|
89
87
|
], Cart.prototype, "coupon", void 0);
|
|
90
|
-
__decorate([
|
|
91
|
-
(0, typegoose_1.prop)({ type: String, enum: enum_1.ValueType, default: enum_1.ValueType.PERCENTAGE }),
|
|
92
|
-
__metadata("design:type", String)
|
|
93
|
-
], Cart.prototype, "discountValueType", void 0);
|
|
94
|
-
__decorate([
|
|
95
|
-
(0, typegoose_1.prop)({ required: true, type: Number }),
|
|
96
|
-
__metadata("design:type", Number)
|
|
97
|
-
], Cart.prototype, "discountValue", void 0);
|
|
98
88
|
exports.Cart = Cart = __decorate([
|
|
99
89
|
(0, typegoose_1.modelOptions)({
|
|
100
90
|
schemaOptions: {
|
|
@@ -111,23 +101,16 @@ exports.Cart = Cart = __decorate([
|
|
|
111
101
|
(0, typegoose_1.index)({ shop: 1 }),
|
|
112
102
|
(0, typegoose_1.index)({ status: 1 }),
|
|
113
103
|
(0, typegoose_1.pre)('save', async function (next) {
|
|
114
|
-
if (!this.slug) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
baseSlug = this.isGroupOrder ? 'group-order' : 'cart';
|
|
125
|
-
}
|
|
126
|
-
const uniqueId = (0, nanoid_1.nanoid)(6);
|
|
104
|
+
if (this.title && !this.slug) {
|
|
105
|
+
const baseSlug = (0, slugify_1.default)(this.title, {
|
|
106
|
+
lower: true,
|
|
107
|
+
strict: true,
|
|
108
|
+
trim: true,
|
|
109
|
+
});
|
|
110
|
+
const uniqueId = (0, crypto_1.randomBytes)(8).toString('hex');
|
|
127
111
|
this.slug = `${baseSlug}-${uniqueId}`;
|
|
128
112
|
}
|
|
129
113
|
next();
|
|
130
114
|
})
|
|
131
115
|
], Cart);
|
|
132
|
-
exports.CartModel = (0, typegoose_1.getModelForClass)(Cart);
|
|
133
116
|
//# sourceMappingURL=cart.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cart.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cart.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"cart.model.js","sourceRoot":"/","sources":["libraries/mongo/models/cart.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAqF;AACrF,6CAAoC;AACpC,4EAAqE;AACrE,kDAAmF;AACnF,0DAAqD;AACrD,sDAA8B;AAC9B,mCAAqC;AAErC,iDAAwC;AACxC,6CAAoC;AAgC7B,IAAM,IAAI,GAAV,MAAM,IAAK,SAAQ,2BAAU;IAE5B,KAAK,CAAU;IAGf,IAAI,CAAU;IAGd,IAAI,CAAa;IAGjB,IAAI,CAAa;IAGjB,eAAe,CAAe;IAG9B,YAAY,CAAW;IAGvB,eAAe,CAAQ;IAGvB,iBAAiB,CAAqB;IAGtC,qBAAqB,CAAU;IAQ/B,MAAM,CAAc;IAGpB,MAAM,CAAe;CAC5B,CAAA;AAtCY,oBAAI;AAET;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;mCACf;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;;kCAChB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;kCAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAI,EAAE,CAAC;;kCAClB;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,2BAAW,EAAE,CAAC;8BACpB,2BAAW;6CAAC;AAG9B;IADN,IAAA,gB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AAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YAC9B,MAAM,QAAQ,GAAG,IAAA,iBAAO,EAAC,IAAI,CAAC,KAAK,EAAE;gBACpC,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,IAAI;gBACZ,IAAI,EAAE,IAAI;aACV,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,IAAA,oBAAW,EAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChD,IAAI,CAAC,IAAI,GAAG,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;QACvC,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,IAAI,CAsChB","sourcesContent":["import { prop, Ref, index, modelOptions, Severity, pre } from '@typegoose/typegoose';\r\nimport { Shop } from './shop.model';\r\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\r\nimport { CartStatus, PaymentPreference, ValueType } from '../../../utilities/enum';\r\nimport { UserAddress } from './shared/address.model';\r\nimport slugify from 'slugify';\r\nimport { randomBytes } from 'crypto';\r\n\r\nimport { Coupon } from './coupon.model';\r\nimport { User } from './user.model';\r\n\r\n/**\r\n * Cart configuration model using Typegoose with automatic slug generation\r\n */\r\n@modelOptions({\r\n\tschemaOptions: {\r\n\t\tcollection: 'carts',\r\n\t\ttoJSON: { virtuals: true },\r\n\t\ttoObject: { virtuals: true },\r\n\t},\r\n\toptions: {\r\n\t\tallowMixed: Severity.ALLOW,\r\n\t},\r\n})\r\n@index({ slug: 1 }, { unique: true })\r\n@index({ user: 1 })\r\n@index({ shop: 1 })\r\n@index({ status: 1 })\r\n@pre<Cart>('save', async function (next) {\r\n\tif (this.title && !this.slug) {\r\n\t\tconst baseSlug = slugify(this.title, {\r\n\t\t\tlower: true,\r\n\t\t\tstrict: true,\r\n\t\t\ttrim: true,\r\n\t\t});\r\n\r\n\t\tconst uniqueId = randomBytes(8).toString('hex');\r\n\t\tthis.slug = `${baseSlug}-${uniqueId}`;\r\n\t}\r\n\tnext();\r\n})\r\nexport class Cart extends TimeStamps {\r\n\t@prop({ trim: true, maxlength: 100 })\r\n\tpublic title?: string;\r\n\r\n\t@prop({ unique: true, sparse: true })\r\n\tpublic slug?: string;\r\n\r\n\t@prop({ required: true, ref: () => User })\r\n\tpublic user!: Ref<User>;\r\n\r\n\t@prop({ required: true, ref: () => Shop })\r\n\tpublic shop!: Ref<Shop>;\r\n\r\n\t@prop({ required: false, type: UserAddress })\r\n\tpublic deliveryAddress?: UserAddress;\r\n\r\n\t@prop({ type: Boolean, default: false })\r\n\tpublic isGroupOrder?: boolean;\r\n\r\n\t@prop({ type: Date })\r\n\tpublic deadlineToOrder?: Date;\r\n\r\n\t@prop({ type: String, enum: PaymentPreference })\r\n\tpublic paymentPreference?: PaymentPreference;\r\n\r\n\t@prop({ type: Number, default: Infinity })\r\n\tpublic spendingLimitForGuest?: number;\r\n\r\n\t@prop({\r\n\t\tenum: CartStatus,\r\n\t\ttype: String,\r\n\t\tdefault: CartStatus.ACTIVE,\r\n\t\trequired: true,\r\n\t})\r\n\tpublic status!: CartStatus;\r\n\r\n\t@prop({ ref: () => Coupon })\r\n\tpublic coupon?: Ref<Coupon>;\r\n}\r\n"]}
|
|
@@ -3,10 +3,9 @@ import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
|
3
3
|
import { ItemType, Status } from '../../../utilities/enum';
|
|
4
4
|
export declare class Category extends TimeStamps {
|
|
5
5
|
name: string;
|
|
6
|
-
image
|
|
6
|
+
image?: string;
|
|
7
7
|
itemType: ItemType;
|
|
8
8
|
parentCategory?: Ref<Category>;
|
|
9
9
|
status?: Status;
|
|
10
|
-
isGlobal?: boolean;
|
|
11
10
|
note?: string;
|
|
12
11
|
}
|
|
@@ -19,7 +19,6 @@ let Category = class Category extends defaultClasses_1.TimeStamps {
|
|
|
19
19
|
itemType;
|
|
20
20
|
parentCategory;
|
|
21
21
|
status;
|
|
22
|
-
isGlobal;
|
|
23
22
|
note;
|
|
24
23
|
};
|
|
25
24
|
exports.Category = Category;
|
|
@@ -28,7 +27,7 @@ __decorate([
|
|
|
28
27
|
__metadata("design:type", String)
|
|
29
28
|
], Category.prototype, "name", void 0);
|
|
30
29
|
__decorate([
|
|
31
|
-
(0, typegoose_1.prop)({
|
|
30
|
+
(0, typegoose_1.prop)({ type: String }),
|
|
32
31
|
__metadata("design:type", String)
|
|
33
32
|
], Category.prototype, "image", void 0);
|
|
34
33
|
__decorate([
|
|
@@ -43,16 +42,12 @@ __decorate([
|
|
|
43
42
|
(0, typegoose_1.prop)({ type: String, enum: enum_1.Status, default: enum_1.Status.ACTIVE }),
|
|
44
43
|
__metadata("design:type", String)
|
|
45
44
|
], Category.prototype, "status", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
48
|
-
__metadata("design:type", Boolean)
|
|
49
|
-
], Category.prototype, "isGlobal", void 0);
|
|
50
45
|
__decorate([
|
|
51
46
|
(0, typegoose_1.prop)({ type: String }),
|
|
52
47
|
__metadata("design:type", String)
|
|
53
48
|
], Category.prototype, "note", void 0);
|
|
54
49
|
exports.Category = Category = __decorate([
|
|
55
50
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'categories' } }),
|
|
56
|
-
(0, typegoose_1.Index)({ name: 1,
|
|
51
|
+
(0, typegoose_1.Index)({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { parentCategory: null, deletedAt: null } })
|
|
57
52
|
], Category);
|
|
58
53
|
//# sourceMappingURL=category.model.js.map
|