@lyxa.ai/core 1.0.326 → 1.0.328

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/cache/settings/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAyC;AACzC,uCAA2C;AAC3C,+CAAkD;AAElD,MAAM,cAAc,GAAG,GAAW,EAAE;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC;IAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,KAAK,CAAC;IACrD,OAAO,YAAY,MAAM,IAAI,WAAW,EAAE,CAAC;AAC5C,CAAC,CAAC;AAGK,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACwB;IAAzD,YAAyD,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAEvF,KAAK,CAAC,WAAW;QAChB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;QAE7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,CAAM,GAAG,CAAC,CAAC;QACjE,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAE1B,MAAM,QAAQ,GAAG,MAAM,qBAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9D,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QAErD,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACnD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,cAAc;QACnB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;QAC7B,MAAM,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAChD,OAAO,qCAAqC,CAAC;IAC9C,CAAC;CACD,CAAA;AArBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,gBAAO,GAAE;IAEI,WAAA,IAAA,eAAM,EAAC,GAAG,EAAE,CAAC,oBAAY,CAAC,CAAA;qCAAgC,oBAAY;GADvE,qBAAqB,CAqBjC","sourcesContent":["import { Service, Inject } from 'typedi';\nimport { RedisService } from '../../redis';\nimport { SettingModel } from '../../mongo/models';\n\nconst getSettingsKey = (): string => {\n\tconst tenant = process.env.tenant || 'lb';\n\tconst environment = process.env.environment || 'dev';\n\treturn `settings:${tenant}:${environment}`;\n};\n\n@Service()\nexport class CachedSettingsService {\n\tconstructor(@Inject(() => RedisService) private readonly redisService: RedisService) {}\n\n\tasync getSettings(): Promise<any> {\n\t\tconst key = getSettingsKey();\n\n\t\tconst cached = await this.redisService.getCachedObject<any>(key);\n\t\tif (cached) return cached;\n\n\t\tconst settings = await SettingModel.findOne({}).lean().exec();\n\t\tif (!settings) throw new Error('Settings not found');\n\n\t\tawait this.redisService.cacheObject(key, settings);\n\t\treturn settings;\n\t}\n\n\tasync updateSettings(): Promise<string> {\n\t\tconst key = getSettingsKey();\n\t\tawait this.redisService.deleteCachedObject(key);\n\t\treturn 'Settings cache cleared successfully';\n\t}\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/cache/settings/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mCAAyC;AACzC,uCAA2C;AAC3C,+CAAkD;AAElD,MAAM,cAAc,GAAG,GAAW,EAAE;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC;IAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,KAAK,CAAC;IACrD,OAAO,YAAY,MAAM,IAAI,WAAW,EAAE,CAAC;AAC5C,CAAC,CAAC;AAGK,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACwB;IAAzD,YAAyD,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAEvF,KAAK,CAAC,WAAW;QAChB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,CAAM,GAAG,CAAC,CAAC;QACjE,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAC1B,MAAM,QAAQ,GAAG,MAAM,qBAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;QAC9D,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACrD,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACnD,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,cAAc;QACnB,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;QAC7B,MAAM,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC;QAChD,OAAO,qCAAqC,CAAC;IAC9C,CAAC;CACD,CAAA;AAlBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,gBAAO,GAAE;IAEI,WAAA,IAAA,eAAM,EAAC,GAAG,EAAE,CAAC,oBAAY,CAAC,CAAA;qCAAgC,oBAAY;GADvE,qBAAqB,CAkBjC","sourcesContent":["import { Service, Inject } from 'typedi';\nimport { RedisService } from '../../redis';\nimport { SettingModel } from '../../mongo/models';\n\nconst getSettingsKey = (): string => {\n\tconst tenant = process.env.tenant || 'lb';\n\tconst environment = process.env.environment || 'dev';\n\treturn `settings:${tenant}:${environment}`;\n};\n\n@Service()\nexport class CachedSettingsService {\n\tconstructor(@Inject(() => RedisService) private readonly redisService: RedisService) {}\n\n\tasync getSettings(): Promise<any> {\n\t\tconst key = getSettingsKey();\n\t\tconst cached = await this.redisService.getCachedObject<any>(key);\n\t\tif (cached) return cached;\n\t\tconst settings = await SettingModel.findOne({}).lean().exec();\n\t\tif (!settings) throw new Error('Settings not found');\n\t\tawait this.redisService.cacheObject(key, settings);\n\t\treturn settings;\n\t}\n\n\tasync updateSettings(): Promise<string> {\t\t\n\t\tconst key = getSettingsKey();\n\t\tawait this.redisService.deleteCachedObject(key);\n\t\treturn 'Settings cache cleared successfully';\n\t}\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import { Ref } from '@typegoose/typegoose';
2
+ import { WeekDay } from '../../../../utilities/enum';
3
+ import { Service } from '../service.model';
4
+ export declare class CapacitySettings {
5
+ day: WeekDay;
6
+ service: Ref<Service>;
7
+ numberOfProfessionals: number;
8
+ }
@@ -0,0 +1,39 @@
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.CapacitySettings = void 0;
13
+ const typegoose_1 = require("@typegoose/typegoose");
14
+ const enum_1 = require("../../../../utilities/enum");
15
+ let CapacitySettings = class CapacitySettings {
16
+ day;
17
+ service;
18
+ numberOfProfessionals;
19
+ };
20
+ exports.CapacitySettings = CapacitySettings;
21
+ __decorate([
22
+ (0, typegoose_1.prop)({ required: true, type: Number, enum: enum_1.WeekDay }),
23
+ __metadata("design:type", Number)
24
+ ], CapacitySettings.prototype, "day", void 0);
25
+ __decorate([
26
+ (0, typegoose_1.prop)({ required: true }),
27
+ __metadata("design:type", Object)
28
+ ], CapacitySettings.prototype, "service", void 0);
29
+ __decorate([
30
+ (0, typegoose_1.prop)({
31
+ required: true,
32
+ type: Number,
33
+ }),
34
+ __metadata("design:type", Number)
35
+ ], CapacitySettings.prototype, "numberOfProfessionals", void 0);
36
+ exports.CapacitySettings = CapacitySettings = __decorate([
37
+ (0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'capacitySettings' } })
38
+ ], CapacitySettings);
39
+ //# sourceMappingURL=capacity-settings.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capacity-settings.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/capacity-settings.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,qDAAqD;AAI9C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAGlB,GAAG,CAAW;IAGd,OAAO,CAAe;IAMtB,qBAAqB,CAAU;CACzC,CAAA;AAbY,4CAAgB;AAGlB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAO,EAAE,CAAC;;6CACjC;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACI;AAMtB;IAJN,IAAA,gBAAI,EAAC;QACF,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,MAAM;KACf,CAAC;;+DACoC;2BAZ7B,gBAAgB;IAD5B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,kBAAkB,EAAE,EAAE,CAAC;GACvD,gBAAgB,CAa5B","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { WeekDay } from '../../../../utilities/enum';\nimport { Service } from '../service.model';\n\n@modelOptions({ schemaOptions: { collection: 'capacitySettings' } })\nexport class CapacitySettings {\n\n @prop({ required: true, type: Number, enum: WeekDay })\n public day!: WeekDay;\n\n @prop({ required: true })\n public service!: Ref<Service>\n\n @prop({\n required: true,\n type: Number,\n })\n public numberOfProfessionals!: number;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export declare class CustomerSupportBatchesSettings {
2
- phoneNumber?: string;
3
- whatsAppNumber?: string;
2
+ customerBatch?: number;
3
+ delayTime?: number;
4
4
  }
@@ -12,16 +12,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CustomerSupportBatchesSettings = void 0;
13
13
  const typegoose_1 = require("@typegoose/typegoose");
14
14
  class CustomerSupportBatchesSettings {
15
- phoneNumber;
16
- whatsAppNumber;
15
+ customerBatch;
16
+ delayTime;
17
17
  }
18
18
  exports.CustomerSupportBatchesSettings = CustomerSupportBatchesSettings;
19
19
  __decorate([
20
- (0, typegoose_1.prop)({ type: String }),
21
- __metadata("design:type", String)
22
- ], CustomerSupportBatchesSettings.prototype, "phoneNumber", void 0);
20
+ (0, typegoose_1.prop)({ type: Number, default: 0, min: 0 }),
21
+ __metadata("design:type", Number)
22
+ ], CustomerSupportBatchesSettings.prototype, "customerBatch", void 0);
23
23
  __decorate([
24
- (0, typegoose_1.prop)({ type: String }),
25
- __metadata("design:type", String)
26
- ], CustomerSupportBatchesSettings.prototype, "whatsAppNumber", void 0);
24
+ (0, typegoose_1.prop)({ type: Number, default: 0, min: 0 }),
25
+ __metadata("design:type", Number)
26
+ ], CustomerSupportBatchesSettings.prototype, "delayTime", void 0);
27
27
  //# sourceMappingURL=customer-support-batches.model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customer-support-batches.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/customer-support-batches.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,8BAA8B;IAEnC,WAAW,CAAU;IAGrB,cAAc,CAAU;CAC/B;AAND,wEAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;mEACK;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;sEACQ","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class CustomerSupportBatchesSettings {\n\t@prop({ type: String })\n\tpublic phoneNumber?: string;\n\n\t@prop({ type: String })\n\tpublic whatsAppNumber?: string;\n}\n"]}
1
+ {"version":3,"file":"customer-support-batches.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/customer-support-batches.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,8BAA8B;IAE1C,aAAa,CAAU;IAGvB,SAAS,CAAU;CACnB;AAND,wEAMC;AAJA;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;qEACpB;AAGvB;IADC,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;;iEACxB","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class CustomerSupportBatchesSettings {\n\t@prop({ type: Number, default: 0, min: 0 })\n\tcustomerBatch?: number;\n\n\t@prop({ type: Number, default: 0, min: 0 })\n\tdelayTime?: number;\n}\n"]}
@@ -1,10 +1,9 @@
1
1
  import { FrequencyConfig } from './frequency-configuration.model';
2
2
  export declare class ServiceOrderSettings {
3
- slotBufferTime: number;
4
- slotInterval: number;
5
- frequencyConfigs: FrequencyConfig[];
6
- servicePreparationTime: number;
7
- maxBookingsPerSlot: number;
8
- autoUrgencyTimeLimit: number;
9
- numberOfProfessionalsPerDay: number;
3
+ slotBufferTime?: number;
4
+ slotInterval?: number;
5
+ frequencyConfigs?: FrequencyConfig[];
6
+ servicePreparationTime?: number;
7
+ maxBookingsPerSlot?: number;
8
+ autoUrgencyTimeLimit?: number;
10
9
  }
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ServiceOrderSettings = void 0;
13
13
  const typegoose_1 = require("@typegoose/typegoose");
14
+ const frequency_configuration_model_1 = require("./frequency-configuration.model");
14
15
  let ServiceOrderSettings = class ServiceOrderSettings {
15
16
  slotBufferTime;
16
17
  slotInterval;
@@ -18,7 +19,6 @@ let ServiceOrderSettings = class ServiceOrderSettings {
18
19
  servicePreparationTime;
19
20
  maxBookingsPerSlot;
20
21
  autoUrgencyTimeLimit;
21
- numberOfProfessionalsPerDay;
22
22
  };
23
23
  exports.ServiceOrderSettings = ServiceOrderSettings;
24
24
  __decorate([
@@ -38,12 +38,11 @@ __decorate([
38
38
  __metadata("design:type", Number)
39
39
  ], ServiceOrderSettings.prototype, "slotInterval", void 0);
40
40
  __decorate([
41
- (0, typegoose_1.prop)({ required: true }),
41
+ (0, typegoose_1.prop)({ type: () => [frequency_configuration_model_1.FrequencyConfig] }),
42
42
  __metadata("design:type", Array)
43
43
  ], ServiceOrderSettings.prototype, "frequencyConfigs", void 0);
44
44
  __decorate([
45
45
  (0, typegoose_1.prop)({
46
- required: true,
47
46
  type: Number,
48
47
  min: 0,
49
48
  max: 200,
@@ -53,7 +52,6 @@ __decorate([
53
52
  ], ServiceOrderSettings.prototype, "servicePreparationTime", void 0);
54
53
  __decorate([
55
54
  (0, typegoose_1.prop)({
56
- required: true,
57
55
  default: 3,
58
56
  min: 1,
59
57
  }),
@@ -61,20 +59,12 @@ __decorate([
61
59
  ], ServiceOrderSettings.prototype, "maxBookingsPerSlot", void 0);
62
60
  __decorate([
63
61
  (0, typegoose_1.prop)({
64
- required: true,
65
62
  default: 6,
66
63
  min: 0,
67
64
  max: 72,
68
65
  }),
69
66
  __metadata("design:type", Number)
70
67
  ], ServiceOrderSettings.prototype, "autoUrgencyTimeLimit", void 0);
71
- __decorate([
72
- (0, typegoose_1.prop)({
73
- required: true,
74
- type: Number,
75
- }),
76
- __metadata("design:type", Number)
77
- ], ServiceOrderSettings.prototype, "numberOfProfessionalsPerDay", void 0);
78
68
  exports.ServiceOrderSettings = ServiceOrderSettings = __decorate([
79
69
  (0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'serviceOrderSettings' } })
80
70
  ], ServiceOrderSettings);
@@ -1 +1 @@
1
- {"version":3,"file":"service-order-settings.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/service-order-settings.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAKxD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAMzB,cAAc,CAAU;IAOxB,YAAY,CAAS;IAGrB,gBAAgB,CAAqB;IASrC,sBAAsB,CAAU;IAOhC,kBAAkB,CAAU;IAQ5B,oBAAoB,CAAU;IAM9B,2BAA2B,CAAU;CAC5C,CAAA;AA/CY,oDAAoB;AAMzB;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,EAAE;QACP,OAAO,EAAE,CAAC;KACV,CAAC;;4DAC6B;AAOxB;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,GAAG;QACR,OAAO,EAAE,EAAE;KACX,CAAC;;0DAC0B;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8DACmB;AASrC;IAPN,IAAA,gBAAI,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,GAAG;QACR,OAAO,EAAE,CAAC;KACV,CAAC;;oEACqC;AAOhC;IALN,IAAA,gBAAI,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,CAAC;QACV,GAAG,EAAE,CAAC;KACN,CAAC;;gEACiC;AAQ5B;IANN,IAAA,gBAAI,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,CAAC;QACV,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,EAAE;KACP,CAAC;;kEACmC;AAM9B;IAJN,IAAA,gBAAI,EAAC;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,MAAM;KACZ,CAAC;;yEAC0C;+BA9ChC,oBAAoB;IADhC,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,EAAE,CAAC;GAC3D,oBAAoB,CA+ChC","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { Vendor } from '../vendor.model';\nimport { FrequencyConfig } from './frequency-configuration.model';\n\n@modelOptions({ schemaOptions: { collection: 'serviceOrderSettings' } })\nexport class ServiceOrderSettings {\n\t@prop({\n\t\tmin: 5,\n\t\tmax: 60,\n\t\tdefault: 5,\n\t})\n\tpublic slotBufferTime!: number; // minutes\n\n\t@prop({\n\t\tmin: 30,\n\t\tmax: 120,\n\t\tdefault: 30,\n\t})\n\tpublic slotInterval: number; // minutes\n\n\t@prop({ required: true })\n\tpublic frequencyConfigs!: FrequencyConfig[];\n\n\t@prop({\n\t\trequired: true,\n\t\ttype: Number,\n\t\tmin: 0,\n\t\tmax: 200,\n\t\tdefault: 3,\n\t})\n\tpublic servicePreparationTime!: number; // hours\n\n\t@prop({\n\t\trequired: true,\n\t\tdefault: 3,\n\t\tmin: 1,\n\t})\n\tpublic maxBookingsPerSlot!: number;\n\n\t@prop({\n\t\trequired: true,\n\t\tdefault: 6,\n\t\tmin: 0,\n\t\tmax: 72,\n\t})\n\tpublic autoUrgencyTimeLimit!: number; // hours\n\n\t@prop({\n\t\trequired: true,\n\t\ttype: Number,\n\t})\n\tpublic numberOfProfessionalsPerDay!: number;\n}\n"]}
1
+ {"version":3,"file":"service-order-settings.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/service-order-settings.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAE/D,mFAAkE;AAG3D,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAMzB,cAAc,CAAU;IAOxB,YAAY,CAAU;IAGtB,gBAAgB,CAAqB;IAQrC,sBAAsB,CAAU;IAMhC,kBAAkB,CAAU;IAO5B,oBAAoB,CAAU;CACrC,CAAA;AAtCY,oDAAoB;AAMzB;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,EAAE;QACP,OAAO,EAAE,CAAC;KACV,CAAC;;4DAC6B;AAOxB;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,GAAG;QACR,OAAO,EAAE,EAAE;KACX,CAAC;;0DAC2B;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,+CAAe,CAAC,EAAE,CAAC;;8DACI;AAQrC;IANN,IAAA,gBAAI,EAAC;QACL,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,GAAG;QACR,OAAO,EAAE,CAAC;KACV,CAAC;;oEACqC;AAMhC;IAJN,IAAA,gBAAI,EAAC;QACL,OAAO,EAAE,CAAC;QACV,GAAG,EAAE,CAAC;KACN,CAAC;;gEACiC;AAO5B;IALN,IAAA,gBAAI,EAAC;QACL,OAAO,EAAE,CAAC;QACV,GAAG,EAAE,CAAC;QACN,GAAG,EAAE,EAAE;KACP,CAAC;;kEACmC;+BArCzB,oBAAoB;IADhC,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,EAAE,CAAC;GAC3D,oBAAoB,CAsChC","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { Vendor } from '../vendor.model';\nimport { FrequencyConfig } from './frequency-configuration.model';\n\n@modelOptions({ schemaOptions: { collection: 'serviceOrderSettings' } })\nexport class ServiceOrderSettings {\n\t@prop({\n\t\tmin: 5,\n\t\tmax: 60,\n\t\tdefault: 5,\n\t})\n\tpublic slotBufferTime?: number; // minutes\n\n\t@prop({\n\t\tmin: 30,\n\t\tmax: 120,\n\t\tdefault: 30,\n\t})\n\tpublic slotInterval?: number; // minutes\n\n\t@prop({ type: () => [FrequencyConfig] })\n\tpublic frequencyConfigs?: FrequencyConfig[];\n\n\t@prop({\n\t\ttype: Number,\n\t\tmin: 0,\n\t\tmax: 200,\n\t\tdefault: 3,\n\t})\n\tpublic servicePreparationTime?: number; // hours\n\n\t@prop({\n\t\tdefault: 3,\n\t\tmin: 1,\n\t})\n\tpublic maxBookingsPerSlot?: number;\n\n\t@prop({\n\t\tdefault: 6,\n\t\tmin: 0,\n\t\tmax: 72,\n\t})\n\tpublic autoUrgencyTimeLimit?: number; // hours\n}\n"]}
@@ -9,6 +9,7 @@ import { Zone } from './zone.model';
9
9
  import { VendorParent } from '.';
10
10
  import { Service } from "./service.model";
11
11
  import { ServiceOrderSettings } from './embedded/service-order-settings.model';
12
+ import { CapacitySettings } from './embedded/capacity-settings.model';
12
13
  export declare class Vendor extends TimeStamps {
13
14
  name: string;
14
15
  ownerName: string;
@@ -25,7 +26,6 @@ export declare class Vendor extends TimeStamps {
25
26
  logo?: string;
26
27
  banner?: string;
27
28
  document?: ShopDocument;
28
- workHourSetting?: WorkHourSetting;
29
29
  vendorActiveTimingsOfCurrentDate?: StartEndTime[];
30
30
  tags?: Ref<Tag>[];
31
31
  isVisibleToUser: boolean;
@@ -37,4 +37,6 @@ export declare class Vendor extends TimeStamps {
37
37
  ordersCount?: number;
38
38
  customersCount?: number;
39
39
  orderSettings?: ServiceOrderSettings;
40
+ capacitySettings?: CapacitySettings[];
41
+ workHourSetting?: WorkHourSetting;
40
42
  }
@@ -25,6 +25,7 @@ const _1 = require(".");
25
25
  const slugify_1 = __importDefault(require("slugify"));
26
26
  const service_model_1 = require("./service.model");
27
27
  const service_order_settings_model_1 = require("./embedded/service-order-settings.model");
28
+ const capacity_settings_model_1 = require("./embedded/capacity-settings.model");
28
29
  let Vendor = class Vendor extends defaultClasses_1.TimeStamps {
29
30
  name;
30
31
  ownerName;
@@ -41,7 +42,6 @@ let Vendor = class Vendor extends defaultClasses_1.TimeStamps {
41
42
  logo;
42
43
  banner;
43
44
  document;
44
- workHourSetting;
45
45
  vendorActiveTimingsOfCurrentDate;
46
46
  tags;
47
47
  isVisibleToUser;
@@ -53,6 +53,8 @@ let Vendor = class Vendor extends defaultClasses_1.TimeStamps {
53
53
  ordersCount;
54
54
  customersCount;
55
55
  orderSettings;
56
+ capacitySettings;
57
+ workHourSetting;
56
58
  };
57
59
  exports.Vendor = Vendor;
58
60
  __decorate([
@@ -115,10 +117,6 @@ __decorate([
115
117
  (0, typegoose_1.prop)({ type: shop_document_model_1.ShopDocument }),
116
118
  __metadata("design:type", shop_document_model_1.ShopDocument)
117
119
  ], Vendor.prototype, "document", void 0);
118
- __decorate([
119
- (0, typegoose_1.prop)({ type: work_hour_model_1.WorkHourSetting }),
120
- __metadata("design:type", work_hour_model_1.WorkHourSetting)
121
- ], Vendor.prototype, "workHourSetting", void 0);
122
120
  __decorate([
123
121
  (0, typegoose_1.prop)({ type: () => [work_hour_model_1.StartEndTime], default: [] }),
124
122
  __metadata("design:type", Array)
@@ -163,6 +161,14 @@ __decorate([
163
161
  (0, typegoose_1.prop)({ type: () => service_order_settings_model_1.ServiceOrderSettings }),
164
162
  __metadata("design:type", service_order_settings_model_1.ServiceOrderSettings)
165
163
  ], Vendor.prototype, "orderSettings", void 0);
164
+ __decorate([
165
+ (0, typegoose_1.prop)({ type: () => [capacity_settings_model_1.CapacitySettings] }),
166
+ __metadata("design:type", Array)
167
+ ], Vendor.prototype, "capacitySettings", void 0);
168
+ __decorate([
169
+ (0, typegoose_1.prop)({ type: work_hour_model_1.WorkHourSetting }),
170
+ __metadata("design:type", work_hour_model_1.WorkHourSetting)
171
+ ], Vendor.prototype, "workHourSetting", void 0);
166
172
  exports.Vendor = Vendor = __decorate([
167
173
  (0, typegoose_1.modelOptions)({
168
174
  schemaOptions: { collection: 'vendors' },
@@ -1 +1 @@
1
- {"version":3,"file":"vendor.model.js","sourceRoot":"/","sources":["libraries/mongo/models/vendor.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAqF;AACrF,4EAAqE;AACrE,kDAAiD;AACjD,wEAA8D;AAC9D,0DAAiD;AACjD,8DAAyE;AACzE,2CAAkC;AAClC,6CAAoC;AACpC,wBAA8C;AAC9C,sDAA8B;AAC9B,mDAA0C;AAC1C,0FAA+E;AA6CxE,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,2BAAU;IAE9B,IAAI,CAAU;IAGd,SAAS,CAAU;IAGnB,KAAK,CAAU;IAGf,IAAI,CAAU;IAGd,MAAM,CAAoB;IAG1B,OAAO,CAAc;IAGrB,MAAM,CAAU;IAGhB,WAAW,CAAU;IAGrB,eAAe,CAAU;IAGzB,sBAAsB,CAAY;IAGlC,OAAO,CAAW;IAGlB,IAAI,CAAe;IAGnB,IAAI,CAAU;IAGd,MAAM,CAAU;IAGhB,QAAQ,CAAgB;IAGxB,eAAe,CAAmB;IAGlC,gCAAgC,CAAkB;IAGlD,IAAI,CAAc;IAGlB,eAAe,CAAW;IAG1B,YAAY,CAAU;IAGtB,0BAA0B,CAAW;IAGrC,sBAAsB,CAAU;IAGhC,2BAA2B,CAAW;IAGtC,SAAS,CAAU;IAGnB,WAAW,CAAS;IAGpB,cAAc,CAAS;IAGvB,aAAa,CAAuB;CAC3C,CAAA;AAjFY,wBAAM;AAEX;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oCAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yCACb;AAGnB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,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,KAAK,EAAE,CAAC;gBAChB,OAAO,IAAI,CAAC,KAAc,CAAC,CAAC;YAC7B,CAAC;QACF,CAAC;QACD,IAAI,CAAC;YACJ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,MAAM,QAAQ,GAAG,IAAA,iBAAO,EAAC,IAAI,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBACnE,IAAI,IAAI,GAAG,QAAQ,CAAC;gBACpB,IAAI,KAAK,GAAG,CAAC,CAAC;gBACd,OAAO,MAAM,cAAW,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;oBAC3C,KAAK,EAAE,CAAC;oBACR,IAAI,GAAG,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC;gBAC/B,CAAC;gBACD,IAAI,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,MAAM,CAiFlB","sourcesContent":["import { modelOptions, prop, Ref, Severity, Index, pre } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Status } from '../../../utilities/enum';\nimport { ShopDocument } from './embedded/shop-document.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 { VendorParent, VendorModel } from '.';\nimport slugify from 'slugify';\nimport { Service } from \"./service.model\";\nimport { ServiceOrderSettings } from './embedded/service-order-settings.model';\n\n@modelOptions({\n\tschemaOptions: { collection: 'vendors' },\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<Vendor>('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 VendorModel.aggregate<{ maxSortingOrder: number }>([\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 VendorModel.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 Vendor 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: () => VendorParent })\n\tpublic parent: Ref<VendorParent>;\n\n\t@prop({ required: true, ref: () => Service })\n\tpublic service: Ref<Service>\n\n\t@prop({ required: true, type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status!: Status;\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, type: () => [String] })\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({ type: WorkHourSetting })\n\tpublic workHourSetting?: WorkHourSetting;\n\n\t@prop({ type: () => [StartEndTime], default: [] })\n\tpublic vendorActiveTimingsOfCurrentDate?: StartEndTime[];\n\n\t@prop({ ref: () => Tag, default: [] })\n\tpublic tags?: Ref<Tag>[];\n\n\t@prop({ required: true, type: Boolean })\n\tpublic isVisibleToUser!: boolean;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: 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({ 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\t@prop({ type: () => ServiceOrderSettings })\n\tpublic orderSettings?: ServiceOrderSettings\n}\n"]}
1
+ {"version":3,"file":"vendor.model.js","sourceRoot":"/","sources":["libraries/mongo/models/vendor.model.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAqF;AACrF,4EAAqE;AACrE,kDAAiD;AACjD,wEAA8D;AAC9D,0DAAiD;AACjD,8DAAyE;AACzE,2CAAkC;AAClC,6CAAoC;AACpC,wBAA8C;AAC9C,sDAA8B;AAC9B,mDAA0C;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,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBACnE,IAAI,IAAI,GAAG,QAAQ,CAAC;gBACpB,IAAI,KAAK,GAAG,CAAC,CAAC;gBACd,OAAO,MAAM,cAAW,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;oBAC3C,KAAK,EAAE,CAAC;oBACR,IAAI,GAAG,GAAG,QAAQ,IAAI,KAAK,EAAE,CAAC;gBAC/B,CAAC;gBACD,IAAI,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,MAAM,CAoFlB","sourcesContent":["import { modelOptions, prop, Ref, Severity, Index, pre } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Status } from '../../../utilities/enum';\nimport { ShopDocument } from './embedded/shop-document.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 { VendorParent, VendorModel } from '.';\nimport slugify from 'slugify';\nimport { Service } from \"./service.model\";\nimport { ServiceOrderSettings } from './embedded/service-order-settings.model';\nimport { CapacitySettings } from './embedded/capacity-settings.model';\n\n@modelOptions({\n\tschemaOptions: { collection: 'vendors' },\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<Vendor>('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 VendorModel.aggregate<{ maxSortingOrder: number }>([\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 VendorModel.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 Vendor 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: () => VendorParent })\n\tpublic parent: Ref<VendorParent>;\n\n\t@prop({ required: true, ref: () => Service })\n\tpublic service: Ref<Service>\n\n\t@prop({ required: true, type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status!: Status;\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, type: () => [String] })\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({ type: () => [StartEndTime], default: [] })\n\tpublic vendorActiveTimingsOfCurrentDate?: StartEndTime[];\n\n\t@prop({ ref: () => Tag, default: [] })\n\tpublic tags?: Ref<Tag>[];\n\n\t@prop({ required: true, type: Boolean })\n\tpublic isVisibleToUser!: boolean;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: 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({ 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\t@prop({ type: () => ServiceOrderSettings })\n\tpublic orderSettings?: ServiceOrderSettings\n\n\t@prop({type: ()=> [CapacitySettings]})\n\tpublic capacitySettings?: CapacitySettings[]\n\n\t@prop({ type: WorkHourSetting })\n\tpublic workHourSetting?: WorkHourSetting;\n}\n"]}
@@ -13,7 +13,6 @@ class SoftDelete {
13
13
  deletedAt: {
14
14
  type: Date,
15
15
  default: null,
16
- index: true,
17
16
  },
18
17
  });
19
18
  }
@@ -73,21 +72,21 @@ class SoftDelete {
73
72
  };
74
73
  schema.statics.deleteRecord = async function (filter, softDelete) {
75
74
  if (softDelete) {
76
- const result = await this.updateOne({ ...filter, deletedAt: null }, { deletedAt: new Date() }).lean();
75
+ const result = await this.updateOne({ ...filter, deletedAt: null }, { deletedAt: new Date() });
77
76
  return Boolean(result.modifiedCount);
78
77
  }
79
78
  else {
80
- const result = await this.deleteOne(filter).lean();
79
+ const result = await this.deleteOne(filter);
81
80
  return Boolean(result.deletedCount);
82
81
  }
83
82
  };
84
83
  schema.statics.deleteRecords = async function (filter, softDelete) {
85
84
  if (softDelete) {
86
- const result = await this.updateMany({ ...filter, deletedAt: null }, { deletedAt: new Date() }).lean();
85
+ const result = await this.updateMany({ ...filter, deletedAt: null }, { deletedAt: new Date() });
87
86
  return Boolean(result.modifiedCount);
88
87
  }
89
88
  else {
90
- const result = await this.deleteMany(filter).lean();
89
+ const result = await this.deleteMany(filter);
91
90
  return Boolean(result.deletedCount);
92
91
  }
93
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"soft-delete-plugin.js","sourceRoot":"/","sources":["libraries/mongo/plugins/soft-delete-plugin.ts"],"names":[],"mappings":";;;AACA,oDAAmF;AAyBnF,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,CAAC,CAAC,CAAC;IACjE,CAAC;IAOM,MAAM,CAAC,WAAW,CACxB,UAAkC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C;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,CAAA;IACF,CAAC;CACD;AA3LD,gCA2LC;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, GetOneQueryDTO } 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\tfindOneRecord(data: GetOneQueryDTO): 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\n\t\tschema.statics.findOneRecord = async function (data: GetOneQueryDTO) {\n\t\t\tconst { query, select, populate } = data;\n\n\t\t\tlet result = this.findOne(query || {});\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;AAyBnF,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;iBACb;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,CAAC,CAAC,CAAC;IACjE,CAAC;IAOM,MAAM,CAAC,WAAW,CACxB,UAAkC;QAElC,MAAM,KAAK,GAA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Q,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;AAvLD,gCAuLC;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, GetOneQueryDTO } 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\tfindOneRecord(data: GetOneQueryDTO): 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},\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() });\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteOne(filter);\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({ ...filter, deletedAt: null }, { deletedAt: new Date() });\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteMany(filter);\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\n\t\tschema.statics.findOneRecord = async function (data: GetOneQueryDTO) {\n\t\t\tconst { query, select, populate } = data;\n\n\t\t\tlet result = this.findOne(query || {});\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 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAA4B;AAC5B,mCAAiC;AAG1B,IAAM,YAAY,GAAlB,MAAM,YAAY;IAChB,YAAY,CAAS;IAE7B,YAAY,QAAgB;QAC3B,IAAI,CAAC,YAAY,GAAG,IAAI,iBAAK,CAAC,QAAQ,EAAE;YACvC,oBAAoB,EAAE,IAAI;SAC1B,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,eAAe,CAAI,GAAW;QAC1C,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEvD,IAAI,aAAa,IAAI,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAM,CAAC;QACvC,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,WAAW,CAAI,GAAW,EAAE,MAAS,EAAE,MAAe;QAClE,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEjD,IAAI,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;QAC/D,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;QACrD,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,GAAW;QAC1C,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,sBAAsB,CAAI,KAAa,EAAE,GAAW;QAChE,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAE/D,IAAI,aAAa,IAAI,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAM,CAAC;QACvC,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,sBAAsB,CAAI,KAAa,EAAE,GAAW,EAAE,MAAS;QAC3E,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,yBAAyB,CAAI,KAAa,EAAE,GAAW;QACnE,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,WAAW,CAAC,GAAW;QAC7B,OAAO,GAAG;aACR,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;aACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;aACpB,WAAW,EAAE,CAAC;IACjB,CAAC;CACD,CAAA;AApEY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CAoExB","sourcesContent":["import Redis from 'ioredis';\nimport { Service } from 'typedi';\n\n@Service()\nexport class RedisService {\n\tprivate _redisClient!: Redis;\n\n\tconstructor(redisURL: string) {\n\t\tthis._redisClient = new Redis(redisURL, {\n\t\t\tmaxRetriesPerRequest: null,\n\t\t});\n\t}\n\n\tget redisClient(): Redis {\n\t\treturn this._redisClient;\n\t}\n\n\tpublic async getCachedObject<T>(key: string): Promise<T | undefined> {\n\t\tconst usageResponse = await this._redisClient.get(key);\n\n\t\tif (usageResponse != undefined) {\n\t\t\treturn JSON.parse(usageResponse) as T;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic async cacheObject<T>(key: string, object: T, expiry?: number): Promise<boolean> {\n\t\tconst stringifiedObject = JSON.stringify(object);\n\n\t\tif (expiry) {\n\t\t\tawait this._redisClient.setex(key, expiry, stringifiedObject);\n\t\t} else {\n\t\t\tawait this._redisClient.set(key, stringifiedObject);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic async deleteCachedObject(key: string): Promise<boolean> {\n\t\tawait this._redisClient.del(key);\n\t\treturn true;\n\t}\n\n\tpublic async getCachedObjectByGroup<T>(group: string, key: string): Promise<T | undefined> {\n\t\tconst usageResponse = await this._redisClient.hget(group, key);\n\n\t\tif (usageResponse != undefined) {\n\t\t\treturn JSON.parse(usageResponse) as T;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic async setCachedObjectByGroup<T>(group: string, key: string, object: T): Promise<boolean> {\n\t\tconst stringifiedObject = JSON.stringify(object);\n\t\tawait this._redisClient.hset(group, key, stringifiedObject);\n\n\t\treturn true;\n\t}\n\n\tpublic async deleteCachedObjectByGroup<T>(group: string, key: string): Promise<boolean> {\n\t\tawait this._redisClient.hdel(group, key);\n\t\treturn true;\n\t}\n\n\tpublic sanitizeKey(key: string) {\n\t\treturn key\n\t\t\t.replace(/[^\\w\\s]/gi, '')\n\t\t\t.replace(/\\s+/g, '-')\n\t\t\t.toLowerCase();\n\t}\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"/","sources":["libraries/redis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAA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G,CAAC,CAAC;QAE/D,IAAI,aAAa,IAAI,SAAS,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAM,CAAC;QACvC,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,sBAAsB,CAAI,KAAa,EAAE,GAAW,EAAE,MAAS;QAC3E,MAAM,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,iBAAiB,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,yBAAyB,CAAI,KAAa,EAAE,GAAW;QACnE,MAAM,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,WAAW,CAAC,GAAW;QAC7B,OAAO,GAAG;aACR,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;aACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;aACpB,WAAW,EAAE,CAAC;IACjB,CAAC;CACD,CAAA;AApEY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,gBAAO,GAAE;;GACG,YAAY,CAoExB","sourcesContent":["import Redis from 'ioredis';\nimport { Service } from 'typedi';\n\n@Service()\nexport class RedisService {\n\tprivate _redisClient!: Redis;\n\n\tconstructor(redisURL: string) {\n\t\tthis._redisClient = new Redis(redisURL, {\n\t\t\tmaxRetriesPerRequest: null,\n\t\t});\n\t}\n\n\tget redisClient(): Redis {\n\t\treturn this._redisClient;\n\t}\n\n\tpublic async getCachedObject<T>(key: string): Promise<T | undefined> {\n\t\tconst usageResponse = await this._redisClient.get(key);\n\n\t\tif (usageResponse != undefined) {\n\t\t\treturn JSON.parse(usageResponse) as T;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic async cacheObject<T>(key: string, object: T, expiry?: number): Promise<boolean> {\n\t\tconst stringifiedObject = JSON.stringify(object);\n\t\t\n\t\tif (expiry) {\n\t\t\tawait this._redisClient.setex(key, expiry, stringifiedObject);\n\t\t} else {\n\t\t\tawait this._redisClient.set(key, stringifiedObject);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tpublic async deleteCachedObject(key: string): Promise<boolean> {\n\t\tawait this._redisClient.del(key);\n\t\treturn true;\n\t}\n\n\tpublic async getCachedObjectByGroup<T>(group: string, key: string): Promise<T | undefined> {\n\t\tconst usageResponse = await this._redisClient.hget(group, key);\n\n\t\tif (usageResponse != undefined) {\n\t\t\treturn JSON.parse(usageResponse) as T;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tpublic async setCachedObjectByGroup<T>(group: string, key: string, object: T): Promise<boolean> {\n\t\tconst stringifiedObject = JSON.stringify(object);\n\t\tawait this._redisClient.hset(group, key, stringifiedObject);\n\n\t\treturn true;\n\t}\n\n\tpublic async deleteCachedObjectByGroup<T>(group: string, key: string): Promise<boolean> {\n\t\tawait this._redisClient.hdel(group, key);\n\t\treturn true;\n\t}\n\n\tpublic sanitizeKey(key: string) {\n\t\treturn key\n\t\t\t.replace(/[^\\w\\s]/gi, '')\n\t\t\t.replace(/\\s+/g, '-')\n\t\t\t.toLowerCase();\n\t}\n}\n"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.0.326
25
+ Version: 1.0.328
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.0.326",
3
+ "version": "1.0.328",
4
4
  "description": "Lyxa type definitions and validation schemas for both frontend and backend",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.0.326",
3
+ "version": "1.0.328",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",