@lyxa.ai/core 1.0.337 → 1.0.338
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,6 +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
7
|
image?: string;
|
|
7
8
|
itemType: ItemType;
|
|
8
9
|
parentCategory?: Ref<Category>;
|
|
@@ -15,6 +15,7 @@ const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
|
15
15
|
const enum_1 = require("../../../utilities/enum");
|
|
16
16
|
let Category = class Category extends defaultClasses_1.TimeStamps {
|
|
17
17
|
name;
|
|
18
|
+
nameNormalized;
|
|
18
19
|
image;
|
|
19
20
|
itemType;
|
|
20
21
|
parentCategory;
|
|
@@ -26,6 +27,10 @@ __decorate([
|
|
|
26
27
|
(0, typegoose_1.prop)({ required: true, type: String, trim: true, maxlength: 30 }),
|
|
27
28
|
__metadata("design:type", String)
|
|
28
29
|
], Category.prototype, "name", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, typegoose_1.prop)({ type: String, trim: true, lowercase: true, select: false }),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], Category.prototype, "nameNormalized", void 0);
|
|
29
34
|
__decorate([
|
|
30
35
|
(0, typegoose_1.prop)({ type: String }),
|
|
31
36
|
__metadata("design:type", String)
|
|
@@ -48,6 +53,32 @@ __decorate([
|
|
|
48
53
|
], Category.prototype, "note", void 0);
|
|
49
54
|
exports.Category = Category = __decorate([
|
|
50
55
|
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'categories' } }),
|
|
51
|
-
(0, typegoose_1.
|
|
56
|
+
(0, typegoose_1.index)({ nameNormalized: 1, itemType: 1 }, {
|
|
57
|
+
unique: true,
|
|
58
|
+
partialFilterExpression: {
|
|
59
|
+
itemType: { $in: [enum_1.ItemType.GROCERY, enum_1.ItemType.PHARMACY] },
|
|
60
|
+
parentCategory: null,
|
|
61
|
+
deletedAt: null,
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
(0, typegoose_1.pre)('save', function (next) {
|
|
65
|
+
if (this.name) {
|
|
66
|
+
this.nameNormalized = this.name.toLowerCase();
|
|
67
|
+
}
|
|
68
|
+
next();
|
|
69
|
+
}),
|
|
70
|
+
(0, typegoose_1.pre)('findOneAndUpdate', function (next) {
|
|
71
|
+
const update = this.getUpdate();
|
|
72
|
+
if (update?.name) {
|
|
73
|
+
update.nameNormalized = update.name.toLowerCase();
|
|
74
|
+
}
|
|
75
|
+
if (update?.$set?.name) {
|
|
76
|
+
update.$set.nameNormalized = update.$set.name.toLowerCase();
|
|
77
|
+
}
|
|
78
|
+
if (update?.$setOnInsert?.name) {
|
|
79
|
+
update.$setOnInsert.nameNormalized = update.$setOnInsert.name.toLowerCase();
|
|
80
|
+
}
|
|
81
|
+
next();
|
|
82
|
+
})
|
|
52
83
|
], Category);
|
|
53
84
|
//# sourceMappingURL=category.model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"category.model.js","sourceRoot":"/","sources":["libraries/mongo/models/category.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
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,gBA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EAAE,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,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"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED