@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 index_1 = require("./index");
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
- if (this.sortingOrder !== undefined)
46
- return;
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,mCAA8C;AAgDvC,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;IA7C1B,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;IAKlE,IAAA,eAAG,EAAiB,MAAM,EAAE,KAAK;QACjC,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS;YAAE,OAAO;QAE5C,MAAM,QAAQ,GAAG,MAAM,2BAAmB,CAAC,OAAO,CAAC;YAClD,SAAS,EAAE,IAAI;YACf,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;SAC/B,CAAC;aACA,IAAI,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,EAAE,CAAC;aAC1B,MAAM,CAAC,cAAc,CAAC;aACtB,IAAI,EAAE,CAAC;QAET,IAAI,CAAC,YAAY,GAAG,CAAC,QAAQ,EAAE,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC,CAAC;IAMD,IAAA,eAAG,EAAiB,kBAAkB,EAAE;QACxC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAS,CAAC;QAEvC,IAAI,CAAC,MAAM;YAAE,OAAO;QAGpB,IAAI,CAAC,MAAM,CAAC,IAAI;YAAE,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QAGnC,IAAI,cAAc,IAAI,MAAM,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;YAC/C,OAAO,MAAM,CAAC,YAAY,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACxB,CAAC,CAAC;GAEW,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 './index';\nimport { Query } from 'mongoose';\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/**\n * PRE SAVE\n * Auto assign sortingOrder if missing\n */\n@pre<ServiceControl>('save', async function () {\n\tif (this.sortingOrder !== undefined) return;\n\n\tconst lastItem = await ServiceControlModel.findOne({\n\t\tdeletedAt: null,\n\t\tsortingOrder: { $exists: true },\n\t})\n\t\t.sort({ sortingOrder: -1 })\n\t\t.select('sortingOrder')\n\t\t.lean();\n\n\tthis.sortingOrder = (lastItem?.sortingOrder ?? 0) + 1;\n})\n\n/**\n * PRE FINDONEANDUPDATE\n * Prevent clearing sortingOrder accidentally\n */\n@pre<ServiceControl>('findOneAndUpdate', function (this: Query<any, ServiceControl>) {\n\tconst update = this.getUpdate() as any;\n\n\tif (!update) return;\n\n\t// normalize $set\n\tif (!update.$set) update.$set = {};\n\n\t// if sortingOrder is explicitly set → allow it\n\tif ('sortingOrder' in update) {\n\t\tupdate.$set.sortingOrder = update.sortingOrder;\n\t\tdelete update.sortingOrder;\n\t}\n\n\tthis.setUpdate(update);\n})\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}"]}
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"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.3.191
25
+ Version: 1.3.192
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.3.191",
3
+ "version": "1.3.192",
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.3.191",
3
+ "version": "1.3.192",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",