@lyxa.ai/core 1.0.336-alpha.2 → 1.0.336-alpha.4

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.
@@ -3,7 +3,7 @@ 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
- nameNormalized: string;
6
+ nameNormalized?: string;
7
7
  image?: string;
8
8
  itemType: ItemType;
9
9
  parentCategory?: Ref<Category>;
@@ -28,7 +28,7 @@ __decorate([
28
28
  __metadata("design:type", String)
29
29
  ], Category.prototype, "name", void 0);
30
30
  __decorate([
31
- (0, typegoose_1.prop)({ required: true, type: String, trim: true, lowercase: true, select: false }),
31
+ (0, typegoose_1.prop)({ type: String, trim: true, lowercase: true, select: false }),
32
32
  __metadata("design:type", String)
33
33
  ], Category.prototype, "nameNormalized", void 0);
34
34
  __decorate([
@@ -75,6 +75,9 @@ exports.Category = Category = __decorate([
75
75
  if (update?.$set?.name) {
76
76
  update.$set.nameNormalized = update.$set.name.toLowerCase();
77
77
  }
78
+ if (update?.$setOnInsert?.name) {
79
+ update.$setOnInsert.nameNormalized = update.$setOnInsert.name.toLowerCase();
80
+ }
78
81
  next();
79
82
  })
80
83
  ], Category);
@@ -1 +1 @@
1
- {"version":3,"file":"category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAA2D;AA+BpD,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,2BAAU;IAEhC,IAAI,CAAU;IAGd,cAAc,CAAS;IAGvB,KAAK,CAAU;IAGf,QAAQ,CAAY;IAGpB,cAAc,CAAiB;IAG/B,MAAM,CAAU;IAGhB,IAAI,CAAU;CACrB,CAAA;AArBY,4BAAQ;AAEb;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAA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AAE,UAAU,IAAI;QACpC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/C,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,eAAG,EAAW,kBAAkB,EAAE,UAAsC,IAAI;QAC5E,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAS,CAAC;QACvC,IAAI,MAAM,EAAE,IAAI,EAAE,CAAC;YAClB,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACnD,CAAC;QACD,IAAI,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC7D,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,QAAQ,CAqBpB","sourcesContent":["import { index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ItemType, Status } from '../../../utilities/enum';\nimport { Query } from 'mongoose';\n\n@modelOptions({ schemaOptions: { collection: 'categories' } })\n@index(\n\t{ nameNormalized: 1, itemType: 1 },\n\t{\n\t\tunique: true,\n\t\tpartialFilterExpression: {\n\t\t\titemType: { $in: [ItemType.GROCERY, ItemType.PHARMACY] },\n\t\t\tparentCategory: null,\n\t\t\tdeletedAt: null,\n\t\t},\n\t}\n)\n@pre<Category>('save', function (next) {\n\tif (this.name) {\n\t\tthis.nameNormalized = this.name.toLowerCase();\n\t}\n\tnext();\n})\n@pre<Category>('findOneAndUpdate', function (this: Query<any, Category>, next) {\n\tconst update = this.getUpdate() as any;\n\tif (update?.name) {\n\t\tupdate.nameNormalized = update.name.toLowerCase();\n\t}\n\tif (update?.$set?.name) {\n\t\tupdate.$set.nameNormalized = update.$set.name.toLowerCase();\n\t}\n\tnext();\n})\nexport class Category extends TimeStamps {\n\t@prop({ required: true, type: String, trim: true, maxlength: 30 })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: String, trim: true, lowercase: true, select: false })\n\tpublic nameNormalized: string;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ ref: () => Category })\n\tpublic parentCategory?: Ref<Category>;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic note?: string;\n}\n"]}
1
+ {"version":3,"file":"category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA2E;AAC3E,4EAAqE;AACrE,kDAA2D;AAkCpD,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,2BAAU;IAEhC,IAAI,CAAU;IAGd,cAAc,CAAU;IAGxB,KAAK,CAAU;IAGf,QAAQ,CAAY;IAGpB,cAAc,CAAiB;IAG/B,MAAM,CAAU;IAGhB,IAAI,CAAU;CACrB,CAAA;AArBY,4BAAQ;AAEb;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;;sCAC7C;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;;gDACpC;AAGxB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;uCACD;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI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AAI,EAAE,IAAI,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC7D,CAAC;QACD,IAAI,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;YAChC,MAAM,CAAC,YAAY,CAAC,cAAc,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC7E,CAAC;QACD,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,QAAQ,CAqBpB","sourcesContent":["import { index, modelOptions, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ItemType, Status } from '../../../utilities/enum';\nimport { Query } from 'mongoose';\n\n@modelOptions({ schemaOptions: { collection: 'categories' } })\n@index(\n\t{ nameNormalized: 1, itemType: 1 },\n\t{\n\t\tunique: true,\n\t\tpartialFilterExpression: {\n\t\t\titemType: { $in: [ItemType.GROCERY, ItemType.PHARMACY] },\n\t\t\tparentCategory: null,\n\t\t\tdeletedAt: null,\n\t\t},\n\t}\n)\n@pre<Category>('save', function (next) {\n\tif (this.name) {\n\t\tthis.nameNormalized = this.name.toLowerCase();\n\t}\n\tnext();\n})\n@pre<Category>('findOneAndUpdate', function (this: Query<any, Category>, next) {\n\tconst update = this.getUpdate() as any;\n\tif (update?.name) {\n\t\tupdate.nameNormalized = update.name.toLowerCase();\n\t}\n\tif (update?.$set?.name) {\n\t\tupdate.$set.nameNormalized = update.$set.name.toLowerCase();\n\t}\n\tif (update?.$setOnInsert?.name) {\n\t\tupdate.$setOnInsert.nameNormalized = update.$setOnInsert.name.toLowerCase();\n\t}\n\tnext();\n})\nexport class Category extends TimeStamps {\n\t@prop({ required: true, type: String, trim: true, maxlength: 30 })\n\tpublic name!: string;\n\n\t@prop({ type: String, trim: true, lowercase: true, select: false })\n\tpublic nameNormalized?: string;\n\n\t@prop({ type: String })\n\tpublic image?: string;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ ref: () => Category })\n\tpublic parentCategory?: Ref<Category>;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic note?: string;\n}\n"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.0.336-alpha.2
25
+ Version: 1.0.336-alpha.4
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.0.336-alpha.2",
3
+ "version": "1.0.336-alpha.4",
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.336-alpha.2",
3
+ "version": "1.0.336-alpha.4",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",