@lyxa.ai/core 1.2.41 → 1.2.43

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,10 +3,12 @@ import { MarketingType } from '../../../../utilities/enum';
3
3
  import { Marketing } from '../marketing.model';
4
4
  import { ProductMarketing } from '../product-marketing.model';
5
5
  import { ShopCategory } from '../shop-category.model';
6
+ import { Product } from '../product.model';
6
7
  export declare class Buy1Get1Marketing extends Marketing {
7
8
  marketingType: MarketingType.BUY1GET1;
8
9
  isEntireMenu?: boolean;
9
10
  products: Ref<ProductMarketing>;
11
+ excludeProducts?: Ref<Product>[];
10
12
  spendLimit?: number;
11
13
  isSpendLimitEnabled?: boolean;
12
14
  isOnlyForSubscriber?: boolean;
@@ -15,10 +15,12 @@ const enum_1 = require("../../../../utilities/enum");
15
15
  const marketing_model_1 = require("../marketing.model");
16
16
  const product_marketing_model_1 = require("../product-marketing.model");
17
17
  const shop_category_model_1 = require("../shop-category.model");
18
+ const product_model_1 = require("../product.model");
18
19
  class Buy1Get1Marketing extends marketing_model_1.Marketing {
19
20
  marketingType = enum_1.MarketingType.BUY1GET1;
20
21
  isEntireMenu;
21
22
  products;
23
+ excludeProducts;
22
24
  spendLimit;
23
25
  isSpendLimitEnabled;
24
26
  isOnlyForSubscriber;
@@ -37,6 +39,10 @@ __decorate([
37
39
  }),
38
40
  __metadata("design:type", Object)
39
41
  ], Buy1Get1Marketing.prototype, "products", void 0);
42
+ __decorate([
43
+ (0, typegoose_1.prop)({ ref: () => product_model_1.Product }),
44
+ __metadata("design:type", Array)
45
+ ], Buy1Get1Marketing.prototype, "excludeProducts", void 0);
40
46
  __decorate([
41
47
  (0, typegoose_1.prop)({ type: Number, default: 0 }),
42
48
  __metadata("design:type", Number)
@@ -1 +1 @@
1
- {"version":3,"file":"buy1-get1-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/buy1-get1-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAA2D;AAC3D,wDAA+C;AAC/C,wEAA8D;AAC9D,gEAAsD;AAEtD,MAAa,iBAAkB,SAAQ,2BAAS;IACxC,aAAa,GAAG,oBAAa,CAAC,QAAiB,CAAC;IAGhD,YAAY,CAAW;IAOvB,QAAQ,CAAwB;IAGhC,UAAU,CAAU;IAGpB,mBAAmB,CAAW;IAG9B,mBAAmB,CAAW;IAG9B,UAAU,CAAsB;CACvC;AAxBD,8CAwBC;AApBO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;uDACV;AAOvB;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,0CAAgB;QAC3B,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,KAAK;KACjB,CAAC;;mDACqC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;qDACR;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8DACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8DACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;;qDACK","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { MarketingType } from '../../../../utilities/enum';\nimport { Marketing } from '../marketing.model';\nimport { ProductMarketing } from '../product-marketing.model';\nimport { ShopCategory } from '../shop-category.model';\n\nexport class Buy1Get1Marketing extends Marketing {\n\tpublic marketingType = MarketingType.BUY1GET1 as const;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isEntireMenu?: boolean;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'marketing',\n\t\tlocalField: '_id',\n\t})\n\tpublic products: Ref<ProductMarketing>;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSpendLimitEnabled?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isOnlyForSubscriber?: boolean;\n\n\t@prop({ ref: () => ShopCategory })\n\tpublic categories: Ref<ShopCategory>[];\n}\n"]}
1
+ {"version":3,"file":"buy1-get1-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/buy1-get1-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAA2D;AAC3D,wDAA+C;AAC/C,wEAA8D;AAC9D,gEAAsD;AACtD,oDAA2C;AAE3C,MAAa,iBAAkB,SAAQ,2BAAS;IACxC,aAAa,GAAG,oBAAa,CAAC,QAAiB,CAAC;IAGhD,YAAY,CAAW;IAOvB,QAAQ,CAAwB;IAGhC,eAAe,CAAkB;IAGjC,UAAU,CAAU;IAGpB,mBAAmB,CAAW;IAG9B,mBAAmB,CAAW;IAG9B,UAAU,CAAsB;CACvC;AA3BD,8CA2BC;AAvBO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;uDACV;AAOvB;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,0CAAgB;QAC3B,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,KAAK;KACjB,CAAC;;mDACqC;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,uBAAO,EAAE,CAAC;;0DACW;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;qDACR;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8DACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;8DACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;;qDACK","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { MarketingType } from '../../../../utilities/enum';\nimport { Marketing } from '../marketing.model';\nimport { ProductMarketing } from '../product-marketing.model';\nimport { ShopCategory } from '../shop-category.model';\nimport { Product } from '../product.model';\n\nexport class Buy1Get1Marketing extends Marketing {\n\tpublic marketingType = MarketingType.BUY1GET1 as const;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isEntireMenu?: boolean;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'marketing',\n\t\tlocalField: '_id',\n\t})\n\tpublic products: Ref<ProductMarketing>;\n\n\t@prop({ ref: () => Product })\n\tpublic excludeProducts?: Ref<Product>[];\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSpendLimitEnabled?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isOnlyForSubscriber?: boolean;\n\n\t@prop({ ref: () => ShopCategory })\n\tpublic categories: Ref<ShopCategory>[];\n}\n"]}
@@ -3,12 +3,14 @@ import { MarketingType, ValueType } from '../../../../utilities/enum';
3
3
  import { Marketing } from '../marketing.model';
4
4
  import { ProductMarketing } from '../product-marketing.model';
5
5
  import { ShopCategory } from '../shop-category.model';
6
+ import { Product } from '../product.model';
6
7
  export declare class DiscountMarketing extends Marketing {
7
8
  marketingType: MarketingType.DISCOUNT;
8
9
  isEntireMenu?: boolean;
9
10
  valueType?: ValueType;
10
11
  value?: number;
11
12
  products: Ref<ProductMarketing>;
13
+ excludeProducts?: Ref<Product>[];
12
14
  maxDiscountPerOrder?: number;
13
15
  isMaxDiscountPerOrderEnabled?: boolean;
14
16
  spendLimit?: number;
@@ -15,12 +15,14 @@ const enum_1 = require("../../../../utilities/enum");
15
15
  const marketing_model_1 = require("../marketing.model");
16
16
  const product_marketing_model_1 = require("../product-marketing.model");
17
17
  const shop_category_model_1 = require("../shop-category.model");
18
+ const product_model_1 = require("../product.model");
18
19
  class DiscountMarketing extends marketing_model_1.Marketing {
19
20
  marketingType = enum_1.MarketingType.DISCOUNT;
20
21
  isEntireMenu;
21
22
  valueType;
22
23
  value;
23
24
  products;
25
+ excludeProducts;
24
26
  maxDiscountPerOrder;
25
27
  isMaxDiscountPerOrderEnabled;
26
28
  spendLimit;
@@ -51,6 +53,10 @@ __decorate([
51
53
  }),
52
54
  __metadata("design:type", Object)
53
55
  ], DiscountMarketing.prototype, "products", void 0);
56
+ __decorate([
57
+ (0, typegoose_1.prop)({ ref: () => product_model_1.Product }),
58
+ __metadata("design:type", Array)
59
+ ], DiscountMarketing.prototype, "excludeProducts", void 0);
54
60
  __decorate([
55
61
  (0, typegoose_1.prop)({ type: Number, default: 0 }),
56
62
  __metadata("design:type", Number)
@@ -1 +1 @@
1
- {"version":3,"file":"discount-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/discount-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAsE;AACtE,wDAA+C;AAC/C,wEAA8D;AAC9D,gEAAsD;AAEtD,MAAa,iBAAkB,SAAQ,2BAAS;IACxC,aAAa,GAAG,oBAAa,CAAC,QAAiB,CAAC;IAGhD,YAAY,CAAW;IAGvB,SAAS,CAAa;IAGtB,KAAK,CAAU;IAOf,QAAQ,CAAwB;IAGhC,mBAAmB,CAAU;IAG7B,4BAA4B,CAAW;IAGvC,UAAU,CAAU;IAGpB,mBAAmB,CAAW;IAG9B,mBAAmB,CAAW;IAG9B,aAAa,CAAU;IAGvB,iBAAiB,CAAa;IAG9B,UAAU,CAAsB;CAC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,kCAAY,EAAE,CAAC;;qDACK","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { MarketingType, ValueType } from '../../../../utilities/enum';\nimport { Marketing } from '../marketing.model';\nimport { ProductMarketing } from '../product-marketing.model';\nimport { ShopCategory } from '../shop-category.model';\n\nexport class DiscountMarketing extends Marketing {\n\tpublic marketingType = MarketingType.DISCOUNT as const;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isEntireMenu?: boolean;\n\n\t@prop({ type: String, enum: ValueType })\n\tpublic valueType?: ValueType;\n\n\t@prop({ type: Number })\n\tpublic value?: number;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'marketing',\n\t\tlocalField: '_id',\n\t})\n\tpublic products: Ref<ProductMarketing>;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic maxDiscountPerOrder?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isMaxDiscountPerOrderEnabled?: boolean;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSpendLimitEnabled?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isOnlyForSubscriber?: boolean;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic categoryValue?: number;\n\n\t@prop({ type: String, enum: ValueType, default: ValueType.PERCENTAGE })\n\tpublic categoryValueType?: ValueType;\n\n\t@prop({ ref: () => ShopCategory })\n\tpublic categories: Ref<ShopCategory>[];\n}"]}
1
+ {"version":3,"file":"discount-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/providers/discount-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAsE;AACtE,wDAA+C;AAC/C,wEAA8D;AAC9D,gEAAsD;AACtD,oDAA2C;AAE3C,MAAa,iBAAkB,SAAQ,2BAAS;IACxC,aAAa,GAAG,oBAAa,CAAC,QAAiB,CAAC;IAGhD,YAAY,CAAW;IAGvB,SAAS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E,KAAK,EAAE,CAAC;;8DACH;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;wDACL;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAS,EAAE,OAAO,EAAE,gBAAS,CAAC,UAAU,EAAE,CAAC;;4DAClC;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,kCAAY,EAAE,CAAC;;qDACK","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { MarketingType, ValueType } from '../../../../utilities/enum';\nimport { Marketing } from '../marketing.model';\nimport { ProductMarketing } from '../product-marketing.model';\nimport { ShopCategory } from '../shop-category.model';\nimport { Product } from '../product.model';\n\nexport class DiscountMarketing extends Marketing {\n\tpublic marketingType = MarketingType.DISCOUNT as const;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isEntireMenu?: boolean;\n\n\t@prop({ type: String, enum: ValueType })\n\tpublic valueType?: ValueType;\n\n\t@prop({ type: Number })\n\tpublic value?: number;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'marketing',\n\t\tlocalField: '_id',\n\t})\n\tpublic products: Ref<ProductMarketing>;\n\n\t@prop({ ref: () => Product })\n\tpublic excludeProducts?: Ref<Product>[];\n\n\t@prop({ type: Number, default: 0 })\n\tpublic maxDiscountPerOrder?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isMaxDiscountPerOrderEnabled?: boolean;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic spendLimit?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isSpendLimitEnabled?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isOnlyForSubscriber?: boolean;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic categoryValue?: number;\n\n\t@prop({ type: String, enum: ValueType, default: ValueType.PERCENTAGE })\n\tpublic categoryValueType?: ValueType;\n\n\t@prop({ ref: () => ShopCategory })\n\tpublic categories: Ref<ShopCategory>[];\n}"]}
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.2.41
25
+ Version: 1.2.43
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.2.41",
3
+ "version": "1.2.43",
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",
@@ -9,8 +9,13 @@ const models_1 = require("../libraries/mongo/models");
9
9
  function normalizeObjectIds(query, objectIdFields) {
10
10
  for (const field of objectIdFields) {
11
11
  if (query?.[field]) {
12
- if (query?.[field]['$in']) {
13
- query[field]['$in'] = query?.[field]['$in'].map((id) => new typegoose_1.mongoose.Types.ObjectId(id));
12
+ if (query?.[field]['$in'] || query?.[field]['$nin']) {
13
+ if (query?.[field]['$in']) {
14
+ query[field]['$in'] = query?.[field]['$in'].map((id) => new typegoose_1.mongoose.Types.ObjectId(id));
15
+ }
16
+ if (query?.[field]['$nin']) {
17
+ query[field]['$nin'] = query?.[field]['$nin'].map((id) => new typegoose_1.mongoose.Types.ObjectId(id));
18
+ }
14
19
  }
15
20
  else {
16
21
  query[field] = new typegoose_1.mongoose.Types.ObjectId(query[field]);
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.js","sourceRoot":"/","sources":["utilities/normalize.ts"],"names":[],"mappings":";;;AAOA,gDAUC;AAOD,sDAeC;AAvCD,oDAAgD;AAChD,6CAA6D;AAC7D,sDAA6D;AAK7D,SAAgB,kBAAkB,CAAC,KAA0B,EAAE,cAAwB;IACtF,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,I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AAC,kBAAkB,EAAE,EAAE,CAAC;KAC/B,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;KAC9B,WAAW,EAAE,CAAC;AANJ,QAAA,aAAa,iBAMT","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { excludeFields, ProjectionType } from './projection';\nimport { getCoreUserModel } from '../libraries/mongo/models';\n\n/**\n * Converts specific fields in query to ObjectIds safely.\n */\nexport function normalizeObjectIds(query: Record<string, any>, objectIdFields: string[]): void {\n\tfor (const field of objectIdFields) {\n\t\tif (query?.[field]) {\n\t\t\tif (query?.[field]['$in']) {\n\t\t\t\tquery[field]['$in'] = query?.[field]['$in'].map((id: string) => new mongoose.Types.ObjectId(id));\n\t\t\t} else {\n\t\t\t\tquery[field] = new mongoose.Types.ObjectId(query[field]);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Adjusts user population rules:\n * - Excludes sensitive user fields\n * - Populates nested `coreUser`\n */\nexport function normalizeUserPopulate(populate?: any[] | any): void {\n\tif (!Array.isArray(populate)) {\n\t\tpopulate = populate ? [populate] : [];\n\t}\n\n\tconst findUserPopulate = populate.find((populate: any) => populate.path === 'user');\n\n\tif (findUserPopulate) {\n\t\tfindUserPopulate.select = excludeFields(findUserPopulate.select, ProjectionType.USER);\n\t\tfindUserPopulate.populate = {\n\t\t\tpath: 'coreUser',\n\t\t\tselect: '-_id name email profilePhoto',\n\t\t\tmodel: getCoreUserModel(),\n\t\t};\n\t}\n}\n\n/**\n * Normalizes a string by removing diacritics (accents) and punctuation/special chars and converting it to lowercase.\n *\n * @param text - The input string to normalize.\n * @returns The normalized string without accents and punctuation/special chars and in lowercase.\n *\n * @example\n * normalizeName(\"Crème Brûlée\"); // \"creme brulee\"\n * normalizeName(\"São Paulo\"); // \"sao paulo\"\n * normalizeName(\"Ka'ak\"); // \"kaak\"\n */\nexport const normalizeName = (text: string) =>\n\ttext\n\t\t.trim()\n\t\t.normalize('NFD')\n\t\t.replace(/[\\u0300-\\u036f]/g, '') // remove accents\n\t\t.replace(/[^a-zA-Z0-9\\s]/g, '') // remove punctuation/special chars\n\t\t.toLowerCase();\n"]}
1
+ {"version":3,"file":"normalize.js","sourceRoot":"/","sources":["utilities/normalize.ts"],"names":[],"mappings":";;;AAOA,gDAeC;AAOD,sDAeC;AA5CD,oDAAgD;AAChD,6CAA6D;AAC7D,sDAA6D;AAK7D,SAAgB,kBAAkB,CAAC,KAA0B,EAAE,cAAwB;IACtF,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;QACpC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;gBACrD,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC3B,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;gBAClG,CAAC;gBACD,IAAI,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;oBAC5B,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;gBACpG,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,oBAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1D,CAAC;QACF,CAAC;IACF,CAAC;AACF,CAAC;AAOD,SAAgB,qBAAqB,CAAC,QAAsB;IAC3D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC9B,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvC,CAAC;IAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IAEpF,IAAI,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,CAAC,MAAM,GAAG,IAAA,0BAAa,EAAC,gBAAgB,CAAC,MAAM,EAAE,2BAAc,CAAC,IAAI,CAAC,CAAC;QACtF,gBAAgB,CAAC,QAAQ,GAAG;YAC3B,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,8BAA8B;YACtC,KAAK,EAAE,IAAA,yBAAgB,GAAE;SACzB,CAAC;IACH,CAAC;AACF,CAAC;AAaM,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE,CAC7C,IAAI;KACF,IAAI,EAAE;KACN,SAAS,CAAC,KAAK,CAAC;KAChB,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;KAC/B,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;KAC9B,WAAW,EAAE,CAAC;AANJ,QAAA,aAAa,iBAMT","sourcesContent":["import { mongoose } from '@typegoose/typegoose';\nimport { excludeFields, ProjectionType } from './projection';\nimport { getCoreUserModel } from '../libraries/mongo/models';\n\n/**\n * Converts specific fields in query to ObjectIds safely.\n */\nexport function normalizeObjectIds(query: Record<string, any>, objectIdFields: string[]): void {\n\tfor (const field of objectIdFields) {\n\t\tif (query?.[field]) {\n\t\t\tif (query?.[field]['$in'] || query?.[field]['$nin']) {\n\t\t\t\tif (query?.[field]['$in']) {\n\t\t\t\t\tquery[field]['$in'] = query?.[field]['$in'].map((id: string) => new mongoose.Types.ObjectId(id));\n\t\t\t\t}\n\t\t\t\tif (query?.[field]['$nin']) {\n\t\t\t\t\tquery[field]['$nin'] = query?.[field]['$nin'].map((id: string) => new mongoose.Types.ObjectId(id));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tquery[field] = new mongoose.Types.ObjectId(query[field]);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Adjusts user population rules:\n * - Excludes sensitive user fields\n * - Populates nested `coreUser`\n */\nexport function normalizeUserPopulate(populate?: any[] | any): void {\n\tif (!Array.isArray(populate)) {\n\t\tpopulate = populate ? [populate] : [];\n\t}\n\n\tconst findUserPopulate = populate.find((populate: any) => populate.path === 'user');\n\n\tif (findUserPopulate) {\n\t\tfindUserPopulate.select = excludeFields(findUserPopulate.select, ProjectionType.USER);\n\t\tfindUserPopulate.populate = {\n\t\t\tpath: 'coreUser',\n\t\t\tselect: '-_id name email profilePhoto',\n\t\t\tmodel: getCoreUserModel(),\n\t\t};\n\t}\n}\n\n/**\n * Normalizes a string by removing diacritics (accents) and punctuation/special chars and converting it to lowercase.\n *\n * @param text - The input string to normalize.\n * @returns The normalized string without accents and punctuation/special chars and in lowercase.\n *\n * @example\n * normalizeName(\"Crème Brûlée\"); // \"creme brulee\"\n * normalizeName(\"São Paulo\"); // \"sao paulo\"\n * normalizeName(\"Ka'ak\"); // \"kaak\"\n */\nexport const normalizeName = (text: string) =>\n\ttext\n\t\t.trim()\n\t\t.normalize('NFD')\n\t\t.replace(/[\\u0300-\\u036f]/g, '') // remove accents\n\t\t.replace(/[^a-zA-Z0-9\\s]/g, '') // remove punctuation/special chars\n\t\t.toLowerCase();\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.2.41",
3
+ "version": "1.2.43",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",