@lyxa.ai/core 1.3.191 → 1.3.192
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.
|
@@ -13,7 +13,8 @@ exports.ServiceControl = void 0;
|
|
|
13
13
|
const enum_1 = require("../../../utilities/enum");
|
|
14
14
|
const typegoose_1 = require("@typegoose/typegoose");
|
|
15
15
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
16
|
-
const
|
|
16
|
+
const _1 = require(".");
|
|
17
|
+
const sorting_order_hooks_1 = require("../utilities/sorting-order.hooks");
|
|
17
18
|
let ServiceControl = class ServiceControl extends defaultClasses_1.TimeStamps {
|
|
18
19
|
name;
|
|
19
20
|
serviceItemType;
|
|
@@ -41,29 +42,9 @@ exports.ServiceControl = ServiceControl = __decorate([
|
|
|
41
42
|
(0, typegoose_1.Index)({ name: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } }),
|
|
42
43
|
(0, typegoose_1.Index)({ serviceItemType: 1, sortingOrder: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } }),
|
|
43
44
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'service-control' } }),
|
|
44
|
-
(0, typegoose_1.pre)('save', async function () {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const lastItem = await index_1.ServiceControlModel.findOne({
|
|
48
|
-
deletedAt: null,
|
|
49
|
-
sortingOrder: { $exists: true },
|
|
50
|
-
})
|
|
51
|
-
.sort({ sortingOrder: -1 })
|
|
52
|
-
.select('sortingOrder')
|
|
53
|
-
.lean();
|
|
54
|
-
this.sortingOrder = (lastItem?.sortingOrder ?? 0) + 1;
|
|
55
|
-
}),
|
|
56
|
-
(0, typegoose_1.pre)('findOneAndUpdate', function () {
|
|
57
|
-
const update = this.getUpdate();
|
|
58
|
-
if (!update)
|
|
59
|
-
return;
|
|
60
|
-
if (!update.$set)
|
|
61
|
-
update.$set = {};
|
|
62
|
-
if ('sortingOrder' in update) {
|
|
63
|
-
update.$set.sortingOrder = update.sortingOrder;
|
|
64
|
-
delete update.sortingOrder;
|
|
65
|
-
}
|
|
66
|
-
this.setUpdate(update);
|
|
45
|
+
(0, typegoose_1.pre)('save', async function (next) {
|
|
46
|
+
await sorting_order_hooks_1.handlePreSaveForSorting.call(this, _1.ServiceControlModel);
|
|
47
|
+
next();
|
|
67
48
|
})
|
|
68
49
|
], ServiceControl);
|
|
69
50
|
//# sourceMappingURL=service-control.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAmD;AACnD,oDAAsE;AACtE,4EAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"service-control.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-control.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAmD;AACnD,oDAAsE;AACtE,4EAAqE;AACrE,wBAAwC;AACxC,0EAA2E;AAcpE,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,2BAAU;IAEtC,IAAI,CAAU;IAGd,eAAe,CAAY;IAG3B,kBAAkB,CAAW;IAG7B,YAAY,CAAU;CAC7B,CAAA;AAZY,wCAAc;AAEnB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CAClB;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,eAAQ,EAAE,CAAC;;uDACP;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;0DACJ;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;oDACM;yBAXjB,cAAc;IAZ1B,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAClF,IAAA,iBAAK,EACL,EAAE,eAAe,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,EACvC,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAC9D;IACA,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,EAAE,CAAC;IAClE,IAAA,eAAG,EAAiB,MAAM,EAAE,KAAK,WAAW,IAAI;QAEhD,MAAM,6CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,sBAAmB,CAAC,CAAC;QAE9D,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,cAAc,CAY1B","sourcesContent":["import { ItemType } from '../../../utilities/enum';\nimport { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ServiceControlModel } from '.';\nimport { handlePreSaveForSorting } from '../utilities/sorting-order.hooks';\n\n@Index({ name: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@Index(\n\t{ serviceItemType: 1, sortingOrder: 1 },\n\t{ unique: true, partialFilterExpression: { deletedAt: null } }\n)\n@modelOptions({ schemaOptions: { collection: 'service-control' } })\n@pre<ServiceControl>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, ServiceControlModel);\n\n\tnext();\n})\nexport class ServiceControl extends TimeStamps {\n\t@prop({ required: true, type: String })\n\tpublic name!: string;\n\n\t@prop({ required: true, enum: ItemType })\n\tpublic serviceItemType!: ItemType;\n\n\t@prop({ required: true, type: Boolean })\n\tpublic isVisibleToUserApp!: boolean;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED