@lyxa.ai/core 1.1.55 → 1.1.57

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.
@@ -0,0 +1,4 @@
1
+ export declare class PreparingTime {
2
+ hours?: number;
3
+ minutes?: number;
4
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PreparingTime = void 0;
13
+ const typegoose_1 = require("@typegoose/typegoose");
14
+ class PreparingTime {
15
+ hours;
16
+ minutes;
17
+ }
18
+ exports.PreparingTime = PreparingTime;
19
+ __decorate([
20
+ (0, typegoose_1.prop)({ type: Number, min: 0, default: 0 }),
21
+ __metadata("design:type", Number)
22
+ ], PreparingTime.prototype, "hours", void 0);
23
+ __decorate([
24
+ (0, typegoose_1.prop)({ type: Number, min: 0, default: 0 }),
25
+ __metadata("design:type", Number)
26
+ ], PreparingTime.prototype, "minutes", void 0);
27
+ //# sourceMappingURL=preparing-time.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preparing-time.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/preparing-time.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,aAAa;IAElB,KAAK,CAAU;IAGf,OAAO,CAAU;CACxB;AAND,sCAMC;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;4CACrB;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8CACnB","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class PreparingTime {\n\t@prop({ type: Number, min: 0, default: 0 })\n\tpublic hours?: number;\n\n\t@prop({ type: Number, min: 0, default: 0 })\n\tpublic minutes?: number;\n}\n"]}
@@ -22,7 +22,7 @@ __decorate([
22
22
  __metadata("design:type", String)
23
23
  ], ProductNutrition.prototype, "name", void 0);
24
24
  __decorate([
25
- (0, typegoose_1.prop)({ required: true, type: String }),
25
+ (0, typegoose_1.prop)({ required: false, type: String }),
26
26
  __metadata("design:type", String)
27
27
  ], ProductNutrition.prototype, "unit", void 0);
28
28
  __decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"product-nutrition.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/product-nutrition.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,gBAAgB;IAE5B,IAAI,CAAS;IAGb,IAAI,CAAS;IAGb,SAAS,CAAS;CAClB;AATD,4CASC;AAPA;IADC,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;;8CACrD;AAGb;IADC,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CAC1B;AAGb;IADC,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;;mDAC7C","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class ProductNutrition {\n\t@prop({ required: true, type: String, trim: true, maxlength: 20 })\n\tname: string;\n\n\t@prop({ required: true, type: String })\n\tunit: string;\n\n\t@prop({ required: true, type: Number, min: 0, max: 999999999 })\n\tunitValue: number;\n}\n"]}
1
+ {"version":3,"file":"product-nutrition.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/product-nutrition.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAE5C,MAAa,gBAAgB;IAE5B,IAAI,CAAS;IAGb,IAAI,CAAS;IAGb,SAAS,CAAS;CAClB;AATD,4CASC;AAPA;IADC,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;;8CACrD;AAGb;IADC,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;8CAC3B;AAGb;IADC,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;;mDAC7C","sourcesContent":["import { prop } from '@typegoose/typegoose';\n\nexport class ProductNutrition {\n\t@prop({ required: true, type: String, trim: true, maxlength: 20 })\n\tname: string;\n\n\t@prop({ required: false, type: String })\n\tunit: string;\n\n\t@prop({ required: true, type: Number, min: 0, max: 999999999 })\n\tunitValue: number;\n}\n"]}
@@ -7,6 +7,7 @@ import { PriceBreakdown } from './embedded/price-breakdown.model';
7
7
  import { AttributeMap } from './embedded/attribute-map.model';
8
8
  import { ShopCategory } from './shop-category.model';
9
9
  import { ProductMarketing } from '.';
10
+ import { PreparingTime } from './embedded/preparing-time.model';
10
11
  export declare class Product extends TimeStamps {
11
12
  productId: string;
12
13
  shop: Ref<Shop>;
@@ -34,7 +35,7 @@ export declare class Product extends TimeStamps {
34
35
  isDrinkIncluded?: boolean;
35
36
  isLargeItem?: boolean;
36
37
  isPreOrderEnabled?: boolean;
37
- numberOfPreparingHours?: number;
38
+ preparingTime?: PreparingTime;
38
39
  orderQuantityLimit?: number;
39
40
  note?: string;
40
41
  status?: Status;
@@ -22,6 +22,7 @@ const _1 = require(".");
22
22
  const sorting_order_hooks_1 = require("../utilities/sorting-order.hooks");
23
23
  const normalize_field_plugin_1 = require("../plugins/normalize-field.plugin");
24
24
  const id_generator_1 = require("../../../utilities/id-generator");
25
+ const preparing_time_model_1 = require("./embedded/preparing-time.model");
25
26
  let Product = class Product extends defaultClasses_1.TimeStamps {
26
27
  productId;
27
28
  shop;
@@ -49,7 +50,7 @@ let Product = class Product extends defaultClasses_1.TimeStamps {
49
50
  isDrinkIncluded;
50
51
  isLargeItem;
51
52
  isPreOrderEnabled;
52
- numberOfPreparingHours;
53
+ preparingTime;
53
54
  orderQuantityLimit;
54
55
  note;
55
56
  status;
@@ -162,9 +163,9 @@ __decorate([
162
163
  __metadata("design:type", Boolean)
163
164
  ], Product.prototype, "isPreOrderEnabled", void 0);
164
165
  __decorate([
165
- (0, typegoose_1.prop)({ type: Number, min: 0 }),
166
- __metadata("design:type", Number)
167
- ], Product.prototype, "numberOfPreparingHours", void 0);
166
+ (0, typegoose_1.prop)({ type: preparing_time_model_1.PreparingTime }),
167
+ __metadata("design:type", preparing_time_model_1.PreparingTime)
168
+ ], Product.prototype, "preparingTime", void 0);
168
169
  __decorate([
169
170
  (0, typegoose_1.prop)({ type: Number, min: 0, max: 999999999 }),
170
171
  __metadata("design:type", Number)
@@ -1 +1 @@
1
- {"version":3,"file":"product.model.js","sourceRoot":"/","sources":["libraries/mongo/models/product.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAmF;AACnF,4EAAqE;AACrE,kDAAsH;AACtH,gF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,EAAE,CAAC,EAAE,EAAE,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IACrF,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,EAAE,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IACzG,IAAA,iBAAK,EAAC,EAAE,cAAc,EAAE,CAAC,EAAE,EAAE,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAC9E,IAAA,eAAG,EAAU,MAAM,EAAE,KAAK,WAAW,IAAI;QAGzC,MAAM,6CAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,eAAY,EAAE;YACtD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,YAAY,EAAE,IAAI,CAAC,YAAY;SAC/B,CAAC,CAAC;QAEH,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;IACD,IAAA,eAAG,EAAU,MAAM,EAAE,KAAK;QAC1B,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,SAAS,GAAG,MAAM,IAAA,yBAAU,EAAC,eAAY,EAAE,kBAAW,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;IACF,CAAC,CAAC;IAED,IAAA,kBAAM,EAAC,6CAAoB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;GACnC,OAAO,CAqGnB","sourcesContent":["import { Index, modelOptions, plugin, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ProductType, ItemType, ProductDietaryType, Status, PriceOption, CounterType } from '../../../utilities/enum';\nimport { ProductNutrition } from './embedded/product-nutrition.model';\nimport { Shop } from './shop.model';\nimport { PriceBreakdown } from './embedded/price-breakdown.model';\nimport { AttributeMap } from './embedded/attribute-map.model';\nimport { ShopCategory } from './shop-category.model';\nimport { CounterModel, ProductMarketing, ProductModel } from '.';\nimport { handlePreSaveForSorting } from '../utilities/sorting-order.hooks';\nimport { handlePreSaveForUniqueId } from '../utilities/unique-id.hooks';\nimport { normalizeFieldPlugin } from '../plugins/normalize-field.plugin';\nimport { generateId } from '../../../utilities/id-generator';\n\n@modelOptions({\n\tschemaOptions: { collection: 'products', toJSON: { virtuals: true }, toObject: { virtuals: true } },\n})\n@Index(\n\t{ nameNormalized: 1, shop: 1, shopCategory: 1 },\n\t{ unique: true, partialFilterExpression: { deletedAt: null } }\n)\n@Index({ shop: 1, shopCategory: 1 }, { partialFilterExpression: { deletedAt: null } })\n@Index({ shop: 1, isStockEnabled: 1, stockQuantity: 1 }, { partialFilterExpression: { deletedAt: null } })\n@Index({ nameNormalized: 1 }, { partialFilterExpression: { deletedAt: null } })\n@pre<Product>('save', async function (next) {\n\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, ProductModel, {\n\t\tshop: this.shop,\n\t\tshopCategory: this.shopCategory,\n\t});\n\n\tnext();\n})\n@pre<Product>('save', async function () {\n\tif (this.isNew) {\n\t\tthis.productId = await generateId(CounterModel, CounterType.ITEM);\n\t}\n})\n\n@plugin(normalizeFieldPlugin, { field: 'name' })\nexport class Product extends TimeStamps {\n\t@prop({ type: String, unique: true, index: true })\n\tpublic productId: string;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ required: true, type: String, trim: true, maxlength: 100 })\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, trim: true, maxlength: 50 })\n\tpublic barcode?: string;\n\n\t@prop({ required: true, ref: () => ShopCategory })\n\tpublic shopCategory!: Ref<ShopCategory>;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ type: String, enum: ProductType })\n\tpublic productType?: ProductType;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: [String], default: [] })\n\tpublic images?: string[];\n\n\t@prop({ type: String, enum: PriceOption, default: PriceOption.SINGLE_PRICE })\n\tpublic priceOption?: PriceOption;\n\n\t@prop({ required: true, type: [PriceBreakdown] })\n\tpublic priceBreakdowns?: PriceBreakdown[];\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic description?: string;\n\n\t@prop({ type: [AttributeMap], default: [] })\n\tpublic attributeMaps?: AttributeMap[];\n\n\t@prop({ ref: () => Product, default: [] })\n\tpublic addons?: Ref<Product>[];\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isNutritionEnabled?: boolean;\n\n\t@prop({ type: Number, min: 0 })\n\tpublic nutritionPackSize?: number;\n\n\t@prop({ type: String })\n\tpublic nutritionPackSizeUnit?: string;\n\n\t@prop({ type: [ProductNutrition], default: [] })\n\tpublic nutritions?: ProductNutrition[];\n\n\t@prop({ type: [String], enum: ProductDietaryType, default: [] })\n\tpublic dietaryTypes?: ProductDietaryType[];\n\n\t@prop({ type: Number, min: -9999, max: 9999 })\n\tpublic storedTemperature?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isStockEnabled?: boolean;\n\n\t@prop({ type: Number, max: 999999999 }) // isStockEnabled: true and stockQuantity < 1 means out of stock\n\tpublic stockQuantity?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isDrinkIncluded?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLargeItem?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isPreOrderEnabled?: boolean;\n\n\t@prop({ type: Number, min: 0 })\n\tpublic numberOfPreparingHours?: number;\n\n\t@prop({ type: Number, min: 0, max: 999999999 }) // 0 means, it is disable\n\tpublic orderQuantityLimit?: number;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic note?: string;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'product',\n\t\tlocalField: '_id',\n\t\tjustOne: true,\n\t})\n\tpublic productMarketing: Ref<ProductMarketing>; // Virtual reference to ProductMarketing\n}\n"]}
1
+ {"version":3,"file":"product.model.js","sourceRoot":"/","sources":["libraries/mongo/models/product.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAmF;AACnF,4EAAqE;AACrE,kDAOiC;AACjC,gFAAsE;AACtE,6CAAoC;AACpC,4EAAkE;AAClE,wEAA8D;AAC9D,+DAAqD;AACrD,wBAAiE;AACjE,0EAA2E;AAE3E,8EAAyE;AACzE,kEAA6D;AAC7D,0EAAgE;AA2BzD,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,2BAAU;IAE/B,SAAS,CAAS;IAGlB,IAAI,CAAa;IAGjB,IAAI,CAAU;IAGd,cAAc,CAAU;IAGxB,OAAO,CAAU;IAGjB,YAAY,CAAqB;IAGjC,QAAQ,CAAY;IAGpB,WAAW,CAAe;IAG1B,IAAI,CAAU;IAGd,MAAM,CAAY;IAGlB,WAAW,CAAe;IAG1B,eAAe,CAAoB;IAGnC,WAAW,CAAU;IAGrB,aAAa,CAAkB;IAG/B,MAAM,CAAkB;IAGxB,kBAAkB,CAAW;IAG7B,iBAAiB,CAAU;IAG3B,qBAAqB,CAAU;IAG/B,UAAU,CAAsB;IAGhC,YAAY,CAAwB;IAGpC,iBAAiB,CAAU;IAG3B,cAAc,CAAW;IAGzB,aAAa,CAAU;IAGvB,eAAe,CAAW;IAG1B,WAAW,CAAW;IAGtB,iBAAiB,CAAW;IAI5B,aAAa,CAAiB;IAG9B,kBAAkB,CAAU;IAG5B,IAAI,CAAU;IAGd,MAAM,CAAU;IAGhB,YAAY,CAAU;IAQtB,gBAAgB,CAAwB;CAC/C,CAAA;AAtGY,0BAAO;AAEZ;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EA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OAAO,CAsGnB","sourcesContent":["import { Index, modelOptions, plugin, pre, prop, Ref } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport {\n\tProductType,\n\tItemType,\n\tProductDietaryType,\n\tStatus,\n\tPriceOption,\n\tCounterType,\n} from '../../../utilities/enum';\nimport { ProductNutrition } from './embedded/product-nutrition.model';\nimport { Shop } from './shop.model';\nimport { PriceBreakdown } from './embedded/price-breakdown.model';\nimport { AttributeMap } from './embedded/attribute-map.model';\nimport { ShopCategory } from './shop-category.model';\nimport { CounterModel, ProductMarketing, ProductModel } from '.';\nimport { handlePreSaveForSorting } from '../utilities/sorting-order.hooks';\nimport { handlePreSaveForUniqueId } from '../utilities/unique-id.hooks';\nimport { normalizeFieldPlugin } from '../plugins/normalize-field.plugin';\nimport { generateId } from '../../../utilities/id-generator';\nimport { PreparingTime } from './embedded/preparing-time.model';\n\n@modelOptions({\n\tschemaOptions: { collection: 'products', toJSON: { virtuals: true }, toObject: { virtuals: true } },\n})\n@Index(\n\t{ nameNormalized: 1, shop: 1, shopCategory: 1 },\n\t{ unique: true, partialFilterExpression: { deletedAt: null } }\n)\n@Index({ shop: 1, shopCategory: 1 }, { partialFilterExpression: { deletedAt: null } })\n@Index({ shop: 1, isStockEnabled: 1, stockQuantity: 1 }, { partialFilterExpression: { deletedAt: null } })\n@Index({ nameNormalized: 1 }, { partialFilterExpression: { deletedAt: null } })\n@pre<Product>('save', async function (next) {\n\t// Set sortingOrder\n\tawait handlePreSaveForSorting.call(this, ProductModel, {\n\t\tshop: this.shop,\n\t\tshopCategory: this.shopCategory,\n\t});\n\n\tnext();\n})\n@pre<Product>('save', async function () {\n\tif (this.isNew) {\n\t\tthis.productId = await generateId(CounterModel, CounterType.ITEM);\n\t}\n})\n@plugin(normalizeFieldPlugin, { field: 'name' })\nexport class Product extends TimeStamps {\n\t@prop({ type: String, unique: true, index: true })\n\tpublic productId: string;\n\n\t@prop({ required: true, ref: () => Shop })\n\tpublic shop!: Ref<Shop>;\n\n\t@prop({ required: true, type: String, trim: true, maxlength: 100 })\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, trim: true, maxlength: 50 })\n\tpublic barcode?: string;\n\n\t@prop({ required: true, ref: () => ShopCategory })\n\tpublic shopCategory!: Ref<ShopCategory>;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ type: String, enum: ProductType })\n\tpublic productType?: ProductType;\n\n\t@prop({ type: String })\n\tpublic logo?: string;\n\n\t@prop({ type: [String], default: [] })\n\tpublic images?: string[];\n\n\t@prop({ type: String, enum: PriceOption, default: PriceOption.SINGLE_PRICE })\n\tpublic priceOption?: PriceOption;\n\n\t@prop({ required: true, type: [PriceBreakdown] })\n\tpublic priceBreakdowns?: PriceBreakdown[];\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic description?: string;\n\n\t@prop({ type: [AttributeMap], default: [] })\n\tpublic attributeMaps?: AttributeMap[];\n\n\t@prop({ ref: () => Product, default: [] })\n\tpublic addons?: Ref<Product>[];\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isNutritionEnabled?: boolean;\n\n\t@prop({ type: Number, min: 0 })\n\tpublic nutritionPackSize?: number;\n\n\t@prop({ type: String })\n\tpublic nutritionPackSizeUnit?: string;\n\n\t@prop({ type: [ProductNutrition], default: [] })\n\tpublic nutritions?: ProductNutrition[];\n\n\t@prop({ type: [String], enum: ProductDietaryType, default: [] })\n\tpublic dietaryTypes?: ProductDietaryType[];\n\n\t@prop({ type: Number, min: -9999, max: 9999 })\n\tpublic storedTemperature?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isStockEnabled?: boolean;\n\n\t@prop({ type: Number, max: 999999999 }) // isStockEnabled: true and stockQuantity < 1 means out of stock\n\tpublic stockQuantity?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isDrinkIncluded?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isLargeItem?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isPreOrderEnabled?: boolean;\n\n\t// this field needed when pre-order enabled\n\t@prop({ type: PreparingTime })\n\tpublic preparingTime?: PreparingTime;\n\n\t@prop({ type: Number, min: 0, max: 999999999 }) // 0 means, it is disable\n\tpublic orderQuantityLimit?: number;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic note?: string;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n\n\t@prop({\n\t\tref: () => ProductMarketing,\n\t\tforeignField: 'product',\n\t\tlocalField: '_id',\n\t\tjustOne: true,\n\t})\n\tpublic productMarketing: Ref<ProductMarketing>; // Virtual reference to ProductMarketing\n}\n"]}
@@ -32,7 +32,7 @@ export declare class User extends TimeStamps {
32
32
  isPhoneVerified?: boolean;
33
33
  onlineStatus?: OnlineStatus;
34
34
  fcmTokens?: string[];
35
- static updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number): Promise<(import("mongoose").Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, User, import("@typegoose/typegoose/lib/types").BeAnyObject> & Omit<User & {
35
+ static updateWallet(this: ReturnModelType<typeof User>, userId: string, amount: number): Promise<(import("mongoose").Document<unknown, import("@typegoose/typegoose/lib/types").BeAnObject, User, import("@typegoose/typegoose/lib/types").BeAnyObject, {}> & Omit<User & {
36
36
  _id: import("mongoose").Types.ObjectId;
37
37
  } & {
38
38
  __v: number;
@@ -22,7 +22,7 @@ Perfect for sharing types between frontend and backend applications.
22
22
 
23
23
  ## Version
24
24
 
25
- Version: 1.1.55
25
+ Version: 1.1.57
26
26
 
27
27
  ## Dependencies
28
28
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/types",
3
- "version": "1.1.55",
3
+ "version": "1.1.57",
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",
@@ -646,7 +646,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
646
646
  totalPages: number;
647
647
  } | undefined;
648
648
  }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
649
- }>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
649
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
650
650
  success: z.ZodBoolean;
651
651
  message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
652
652
  data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -684,83 +684,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
684
684
  totalPages: number;
685
685
  } | undefined;
686
686
  }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
687
- }>, any>[k]; } : never, z.baseObjectInputType<{
688
- success: z.ZodBoolean;
689
- message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
690
- data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
691
- metadata: z.ZodOptional<z.ZodObject<{
692
- page: z.ZodNumber;
693
- size: z.ZodNumber;
694
- totalElements: z.ZodNumber;
695
- totalPages: z.ZodNumber;
696
- }, "strip", z.ZodTypeAny, {
697
- size: number;
698
- page: number;
699
- totalElements: number;
700
- totalPages: number;
701
- }, {
702
- size: number;
703
- page: number;
704
- totalElements: number;
705
- totalPages: number;
706
- }>>;
707
- documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
708
- }, "strip", z.ZodTypeAny, {
709
- documents: T[];
710
- metadata?: {
711
- size: number;
712
- page: number;
713
- totalElements: number;
714
- totalPages: number;
715
- } | undefined;
716
- }, {
717
- documents: T[];
718
- metadata?: {
719
- size: number;
720
- page: number;
721
- totalElements: number;
722
- totalPages: number;
723
- } | undefined;
724
- }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
725
- }> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
726
- success: z.ZodBoolean;
727
- message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
728
- data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
729
- metadata: z.ZodOptional<z.ZodObject<{
730
- page: z.ZodNumber;
731
- size: z.ZodNumber;
732
- totalElements: z.ZodNumber;
733
- totalPages: z.ZodNumber;
734
- }, "strip", z.ZodTypeAny, {
735
- size: number;
736
- page: number;
737
- totalElements: number;
738
- totalPages: number;
739
- }, {
740
- size: number;
741
- page: number;
742
- totalElements: number;
743
- totalPages: number;
744
- }>>;
745
- documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
746
- }, "strip", z.ZodTypeAny, {
747
- documents: T[];
748
- metadata?: {
749
- size: number;
750
- page: number;
751
- totalElements: number;
752
- totalPages: number;
753
- } | undefined;
754
- }, {
755
- documents: T[];
756
- metadata?: {
757
- size: number;
758
- page: number;
759
- totalElements: number;
760
- totalPages: number;
761
- } | undefined;
762
- }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
763
- }>[k_1]; } : never>;
687
+ }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
764
688
  export type PaginatedDTO<T> = {
765
689
  metadata: DTO<typeof metadataSchema>;
766
690
  documents: T[];
@@ -1,6 +1,6 @@
1
- import { z } from 'zod';
1
+ import { z, ZodTypeAny } from 'zod';
2
2
  type ReadonlyNonEmptyArray<T> = readonly [T, ...T[]];
3
- export interface FilterSchemaConfig<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {}, TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends ReadonlyNonEmptyArray<string> | [] = []> {
3
+ export interface FilterSchemaConfig<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {}, TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends Record<string, ZodTypeAny> = {}> {
4
4
  selectableFields?: TSelect;
5
5
  populatableFields?: TPopulate;
6
6
  searchableFields?: TSearch;
@@ -19,11 +19,10 @@ export type PopulateObject<TPath extends string, TSelect extends ReadonlyNonEmpt
19
19
  };
20
20
  populate?: never;
21
21
  };
22
- export type FilterDTO<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends ReadonlyNonEmptyArray<string> | [] = [], TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends ReadonlyNonEmptyArray<string> | [] = []> = {
22
+ export type FilterDTO<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends ReadonlyNonEmptyArray<string> | [] = [], TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends Record<string, ZodTypeAny> = {}> = {
23
23
  size?: number;
24
24
  page?: number;
25
25
  sort?: Record<string, 1 | -1>;
26
- query?: TQuery extends ReadonlyNonEmptyArray<string> ? Partial<Record<TQuery[number], any>> : never;
27
26
  select?: TSelect extends ReadonlyNonEmptyArray<string> ? Partial<Record<TSelect[number], 0 | 1>> : never;
28
27
  populate?: TPopulate extends ReadonlyNonEmptyArray<string> ? {
29
28
  [P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;
@@ -34,6 +33,9 @@ export type FilterDTO<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], T
34
33
  searchKey: string;
35
34
  searchFields?: TSearch[number][];
36
35
  } : never;
36
+ query?: {
37
+ [K in keyof TQuery]?: z.infer<TQuery[K]>;
38
+ };
37
39
  };
38
- export declare function createFilterSchema<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {}, TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends ReadonlyNonEmptyArray<string> | [] = []>(config: FilterSchemaConfig<TSelect, TPopulate, TSearch, TQuery>): z.ZodType<FilterDTO<TSelect, keyof TPopulate extends never ? [] : readonly [keyof TPopulate & string, ...(keyof TPopulate & string)[]], TSearch, TQuery>>;
40
+ export declare function createFilterSchema<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {}, TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends Record<string, ZodTypeAny> = {}>(config: FilterSchemaConfig<TSelect, TPopulate, TSearch, TQuery>): z.ZodType<FilterDTO<TSelect, keyof TPopulate extends never ? [] : readonly [keyof TPopulate & string, ...(keyof TPopulate & string)[]], TSearch, TQuery>>;
39
41
  export {};
@@ -58,8 +58,12 @@ function createFilterSchema(config) {
58
58
  })
59
59
  .optional();
60
60
  }
61
- if (queryableFields?.length) {
62
- schemaShape.query = zod_1.z.record(zod_1.z.enum([...queryableFields]), zod_1.z.any()).optional();
61
+ if (queryableFields && Object.keys(queryableFields).length) {
62
+ const queryShape = {};
63
+ for (const key in queryableFields) {
64
+ queryShape[key] = queryableFields[key].optional();
65
+ }
66
+ schemaShape.query = zod_1.z.object(queryShape).optional();
63
67
  }
64
68
  return zod_1.z.object(schemaShape);
65
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"filter-schema.factory.js","sourceRoot":"/","sources":["utilities/validation/filter-schema.factory.ts"],"names":[],"mappings":";;AAuDA,gDAiGC;AAxJD,6BAAoC;AAqDpC,MAAM,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF,SAAgB,kBAAkB,CAKhC,MAA+D;IAChE,MAAM,EACL,gBAAgB,EAChB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CAAC,CAAC,WAAW,EAAE,OAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAA8C,CAAC;iBACvF,QAAQ,EAAE,CAAC;QACd,CAAC;IACF,CAAC;IAGD,IAAI,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAC9B,WAAW,CAAC,MAAM,GAAG,OAAC;aACpB,MAAM,CAAC;YACP,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;YACrB,YAAY,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,IAAI,CAAC,CAAC,GAAG,gBAAgB,CAA0B,CAAC,CAAC,CAAC,QAAQ,EAAE;SACxF,CAAC;aACD,QAAQ,EAAE,CAAC;IACd,CAAC;IAGD,IAAI,eAAe,EAAE,MAAM,EAAE,CAAC;QAC7B,WAAW,CAAC,KAAK,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,IAAI,CAAC,CAAC,GAAG,eAAe,CAA0B,CAAC,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;IACzG,CAAC;IAMD,OAAO,OAAC,CAAC,MAAM,CAAC,WAAW,CAE1B,CAAC;AACH,CAAC","sourcesContent":["import { z, ZodTypeAny } from 'zod';\n\ntype ReadonlyNonEmptyArray<T> = readonly [T, ...T[]];\n\nexport interface FilterSchemaConfig<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {},\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends ReadonlyNonEmptyArray<string> | [] = [],\n> {\n\tselectableFields?: TSelect;\n\tpopulatableFields?: TPopulate;\n\tsearchableFields?: TSearch;\n\tqueryableFields?: TQuery;\n\tmaxSize?: number;\n\tdefaultSize?: number;\n}\n\nexport type PopulateObject<TPath extends string, TSelect extends ReadonlyNonEmptyArray<string>> = {\n\tpath: TPath;\n\tselect: Partial<Record<TSelect[number], 0 | 1>>;\n\tmatch?: Partial<Record<TSelect[number], any>>;\n\toptions?: { sort?: Record<string, 1 | -1>; limit?: number; skip?: number };\n\tpopulate?: never; // Can be recursively extended\n};\n\nexport type FilterDTO<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends ReadonlyNonEmptyArray<string> | [] = [],\n> = {\n\tsize?: number;\n\tpage?: number;\n\tsort?: Record<string, 1 | -1>;\n\tquery?: TQuery extends ReadonlyNonEmptyArray<string> ? Partial<Record<TQuery[number], any>> : never;\n\tselect?: TSelect extends ReadonlyNonEmptyArray<string> ? Partial<Record<TSelect[number], 0 | 1>> : never;\n\tpopulate?: TPopulate extends ReadonlyNonEmptyArray<string>\n\t\t?\n\t\t\t\t| {\n\t\t\t\t\t\t[P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;\n\t\t\t\t }[TPopulate[number]]\n\t\t\t\t| Array<\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;\n\t\t\t\t\t\t}[TPopulate[number]]\n\t\t\t\t >\n\t\t: never;\n\tsearch?: TSearch extends ReadonlyNonEmptyArray<string>\n\t\t? { searchKey: string; searchFields?: TSearch[number][] }\n\t\t: never;\n};\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nexport function createFilterSchema<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {},\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends ReadonlyNonEmptyArray<string> | [] = [],\n>(config: FilterSchemaConfig<TSelect, TPopulate, TSearch, TQuery>) {\n\tconst {\n\t\tselectableFields,\n\t\tpopulatableFields,\n\t\tsearchableFields,\n\t\tqueryableFields,\n\t\tmaxSize = 100,\n\t\tdefaultSize = 10,\n\t} = config;\n\n\t// Derive populatableFields array from the keys\n\tconst populateKeys = populatableFields ? (Object.keys(populatableFields) as (keyof TPopulate)[]) : [];\n\n\tconst schemaShape: Record<string, any> = {\n\t\tsize: z.number().min(1).max(maxSize).optional().default(defaultSize),\n\t\tpage: z.number().min(1).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t};\n\n\t// Select\n\tif (selectableFields?.length) {\n\t\tschemaShape.select = z\n\t\t\t.record(z.enum([...selectableFields] as [string, ...string[]]), z.union([z.literal(0), z.literal(1)]))\n\t\t\t.optional();\n\t}\n\n\t// Populate\n\tif (populateKeys.length) {\n\t\tconst populateSchemaMap: Record<string, ZodTypeAny> = {};\n\n\t\tfor (const path of populateKeys) {\n\t\t\tconst allowedSelects = populatableFields![path] as ReadonlyNonEmptyArray<string>; // <- assert iterable\n\n\t\t\tpopulateSchemaMap[path as string] = z.lazy(() =>\n\t\t\t\tz.object({\n\t\t\t\t\tpath: z.literal(path as string),\n\t\t\t\t\tselect: z\n\t\t\t\t\t\t.record(\n\t\t\t\t\t\t\tz.enum([...allowedSelects] as [string, ...string[]]),\n\t\t\t\t\t\t\tz.union([z.literal(0), z.literal(1)])\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.optional(),\n\t\t\t\t\tmatch: z.record(z.enum([...allowedSelects] as [string, ...string[]]), z.any()).optional(),\n\t\t\t\t\toptions: z\n\t\t\t\t\t\t.object({\n\t\t\t\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\t\t\t\tlimit: z.number().optional(),\n\t\t\t\t\t\t\tskip: z.number().optional(),\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.optional(),\n\t\t\t\t\tpopulate: z.never(),\n\t\t\t\t})\n\t\t\t) as ZodTypeAny;\n\t\t}\n\n\t\tconst populateSchemas = Object.values(populateSchemaMap);\n\n\t\tif (populateSchemas.length > 0) {\n\t\t\tlet unionSchema: ZodTypeAny;\n\t\t\tif (populateSchemas.length === 1) {\n\t\t\t\tunionSchema = z.union([populateSchemas[0], populateSchemas[0]]);\n\t\t\t} else {\n\t\t\t\tunionSchema = z.union(populateSchemas as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]);\n\t\t\t}\n\t\t\tschemaShape.populate = z\n\t\t\t\t.union([unionSchema, z.array(unionSchema)] as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]])\n\t\t\t\t.optional();\n\t\t}\n\t}\n\n\t// Search\n\tif (searchableFields?.length) {\n\t\tschemaShape.search = z\n\t\t\t.object({\n\t\t\t\tsearchKey: z.string(),\n\t\t\t\tsearchFields: z.array(z.enum([...searchableFields] as [string, ...string[]])).optional(),\n\t\t\t})\n\t\t\t.optional();\n\t}\n\n\t// Query\n\tif (queryableFields?.length) {\n\t\tschemaShape.query = z.record(z.enum([...queryableFields] as [string, ...string[]]), z.any()).optional();\n\t}\n\n\ttype KeysToReadonlyNonEmptyArray<T> = keyof T extends never\n\t\t? []\n\t\t: readonly [keyof T & string, ...(keyof T & string)[]];\n\n\treturn z.object(schemaShape) as z.ZodType<\n\t\tFilterDTO<TSelect, KeysToReadonlyNonEmptyArray<TPopulate>, TSearch, TQuery>\n\t>;\n}\n\n/**\n * @Example\n *\n * const UserFilterSchema = createFilterSchemaStrict({\n * \tselectableFields: ['_id', 'name', 'email', 'role'] as const,\n * \tpopulatableFields: ['organization'] as const,\n * \tpopulateSelectMap: { organization: ['_id', 'name', 'address'] as const },\n * \tsearchableFields: ['name', 'email'] as const,\n * \tqueryableFields: ['role', 'active'] as const,\n * });\n *\n * type UserFilter = z.infer<typeof UserFilterSchema>;\n *\n * ✅ valid\n * const validFilter: UserFilter = {\n * \tselect: { name: 1, email: 1 },\n * \tquery: { role: 'admin', active: true },\n * \tpopulate: { path: 'organization', select: { name: 1 } },\n * \tsearch: { searchKey: 'john', searchFields: ['name', 'email'] },\n * \tpage: 1,\n * \tsize: 20,\n * };\n *\n * ❌ invalid - TypeScript will reject anything outside the rules\n * const invalidFilter: UserFilter = {\n * \tselect: { password: 1 }, // ❌ not allowed\n * \tquery: { status: true }, // ❌ not allowed\n * \tpopulate: { path: 'organization', select: { name: 1 } }, // ❌ not allowed\n * \tsearch: { searchKey: 'x', searchFields: ['unknown'] }, // ❌ not allowed\n * };\n *\n */"]}
1
+ {"version":3,"file":"filter-schema.factory.js","sourceRoot":"/","sources":["utilities/validation/filter-schema.factory.ts"],"names":[],"mappings":";;AAuDA,gDAoGC;AA3JD,6BAAoC;AAqDpC,MAAM,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF,SAAgB,kBAAkB,CAKhC,MAA+D;IAChE,MAAM,EACL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,OAAO,GAAG,GAAG,EACb,WAAW,GAAG,EAAE,GAChB,GAAG,MAAM,CAAC;IAEX,MAAM,YAAY,GAAG,iBAAiB,CAAC,CAAC,CAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAyB,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtG,MAAM,WAAW,GAAwB;QACxC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC;QACpE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7C,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE;KAC3B,CAAC;IAGF,IAAI,gBAAgB,EAAE,MAAM,EAAE,C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GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QACnD,CAAC;QACD,WAAW,CAAC,KAAK,GAAG,OAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;IACrD,CAAC;IAMD,OAAO,OAAC,CAAC,MAAM,CAAC,WAAW,CAE1B,CAAC;AACH,CAAC","sourcesContent":["import { z, ZodTypeAny } from 'zod';\n\ntype ReadonlyNonEmptyArray<T> = readonly [T, ...T[]];\n\nexport interface FilterSchemaConfig<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {},\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends Record<string, ZodTypeAny> = {},\n> {\n\tselectableFields?: TSelect;\n\tpopulatableFields?: TPopulate;\n\tsearchableFields?: TSearch;\n\tqueryableFields?: TQuery;\n\tmaxSize?: number;\n\tdefaultSize?: number;\n}\n\nexport type PopulateObject<TPath extends string, TSelect extends ReadonlyNonEmptyArray<string>> = {\n\tpath: TPath;\n\tselect: Partial<Record<TSelect[number], 0 | 1>>;\n\tmatch?: Partial<Record<TSelect[number], any>>;\n\toptions?: { sort?: Record<string, 1 | -1>; limit?: number; skip?: number };\n\tpopulate?: never;\n};\n\nexport type FilterDTO<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends Record<string, ZodTypeAny> = {},\n> = {\n\tsize?: number;\n\tpage?: number;\n\tsort?: Record<string, 1 | -1>;\n\tselect?: TSelect extends ReadonlyNonEmptyArray<string> ? Partial<Record<TSelect[number], 0 | 1>> : never;\n\tpopulate?: TPopulate extends ReadonlyNonEmptyArray<string>\n\t\t?\n\t\t\t\t| {\n\t\t\t\t\t\t[P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;\n\t\t\t\t }[TPopulate[number]]\n\t\t\t\t| Array<\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;\n\t\t\t\t\t\t}[TPopulate[number]]\n\t\t\t\t >\n\t\t: never;\n\tsearch?: TSearch extends ReadonlyNonEmptyArray<string>\n\t\t? { searchKey: string; searchFields?: TSearch[number][] }\n\t\t: never;\n\tquery?: { [K in keyof TQuery]?: z.infer<TQuery[K]> };\n};\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nexport function createFilterSchema<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {},\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends Record<string, ZodTypeAny> = {},\n>(config: FilterSchemaConfig<TSelect, TPopulate, TSearch, TQuery>) {\n\tconst {\n\t\tselectableFields,\n\t\tpopulatableFields,\n\t\tsearchableFields,\n\t\tqueryableFields,\n\t\tmaxSize = 100,\n\t\tdefaultSize = 10,\n\t} = config;\n\n\tconst populateKeys = populatableFields ? (Object.keys(populatableFields) as (keyof TPopulate)[]) : [];\n\n\tconst schemaShape: Record<string, any> = {\n\t\tsize: z.number().min(1).max(maxSize).optional().default(defaultSize),\n\t\tpage: z.number().min(1).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t};\n\n\t// Select\n\tif (selectableFields?.length) {\n\t\tschemaShape.select = z\n\t\t\t.record(z.enum([...selectableFields] as [string, ...string[]]), z.union([z.literal(0), z.literal(1)]))\n\t\t\t.optional();\n\t}\n\n\t// Populate\n\tif (populateKeys.length) {\n\t\tconst populateSchemaMap: Record<string, ZodTypeAny> = {};\n\n\t\tfor (const path of populateKeys) {\n\t\t\tconst allowedSelects = populatableFields![path] as ReadonlyNonEmptyArray<string>;\n\n\t\t\tpopulateSchemaMap[path as string] = z.lazy(() =>\n\t\t\t\tz.object({\n\t\t\t\t\tpath: z.literal(path as string),\n\t\t\t\t\tselect: z\n\t\t\t\t\t\t.record(\n\t\t\t\t\t\t\tz.enum([...allowedSelects] as [string, ...string[]]),\n\t\t\t\t\t\t\tz.union([z.literal(0), z.literal(1)])\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.optional(),\n\t\t\t\t\tmatch: z.record(z.enum([...allowedSelects] as [string, ...string[]]), z.any()).optional(),\n\t\t\t\t\toptions: z\n\t\t\t\t\t\t.object({\n\t\t\t\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\t\t\t\tlimit: z.number().optional(),\n\t\t\t\t\t\t\tskip: z.number().optional(),\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.optional(),\n\t\t\t\t\tpopulate: z.never(),\n\t\t\t\t})\n\t\t\t) as ZodTypeAny;\n\t\t}\n\n\t\tconst populateSchemas = Object.values(populateSchemaMap);\n\n\t\tif (populateSchemas.length > 0) {\n\t\t\tlet unionSchema: ZodTypeAny;\n\t\t\tif (populateSchemas.length === 1) {\n\t\t\t\tunionSchema = z.union([populateSchemas[0], populateSchemas[0]]);\n\t\t\t} else {\n\t\t\t\tunionSchema = z.union(populateSchemas as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]);\n\t\t\t}\n\t\t\tschemaShape.populate = z\n\t\t\t\t.union([unionSchema, z.array(unionSchema)] as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]])\n\t\t\t\t.optional();\n\t\t}\n\t}\n\n\t// Search\n\tif (searchableFields?.length) {\n\t\tschemaShape.search = z\n\t\t\t.object({\n\t\t\t\tsearchKey: z.string(),\n\t\t\t\tsearchFields: z.array(z.enum([...searchableFields] as [string, ...string[]])).optional(),\n\t\t\t})\n\t\t\t.optional();\n\t}\n\n\t// Query\n\tif (queryableFields && Object.keys(queryableFields).length) {\n\t\tconst queryShape: Record<string, ZodTypeAny> = {};\n\t\tfor (const key in queryableFields) {\n\t\t\tqueryShape[key] = queryableFields[key].optional();\n\t\t}\n\t\tschemaShape.query = z.object(queryShape).optional();\n\t}\n\n\ttype KeysToReadonlyNonEmptyArray<T> = keyof T extends never\n\t\t? []\n\t\t: readonly [keyof T & string, ...(keyof T & string)[]];\n\n\treturn z.object(schemaShape) as z.ZodType<\n\t\tFilterDTO<TSelect, KeysToReadonlyNonEmptyArray<TPopulate>, TSearch, TQuery>\n\t>;\n}\n\n/**\n *\n *\n * const UserFilterSchema = createFilterSchema({\n * \tselectableFields: ['_id', 'name', 'email', 'role'] as const,\n * \tpopulatableFields: { organization: ['_id', 'name', 'address'] as const },\n * \tsearchableFields: ['name', 'email'] as const,\n * \tqueryableFields: {\n * \t\trole: z.string(),\n * \t\tactive: z.boolean(),\n * \t},\n * });\n *\n * type UserFilter = z.infer<typeof UserFilterSchema>;\n *\n * const validFilter: UserFilter = {\n * \tselect: { name: 1, email: 1 },\n * \tquery: { role: 'admin', active: true },\n * \tpopulate: { path: 'organization', select: { name: 1 } },\n * \tsearch: { searchKey: 'john', searchFields: ['name', 'email'] },\n * \tpage: 1,\n * \tsize: 20,\n * };\n *\n * ❌ TypeScript will reject invalid assignments\n * const invalidFilter: UserFilter = {\n * \tselect: { password: 1 }, // ❌ not allowed\n * \tquery: { role: 123, active: 'yes' }, // ❌ not allowed\n * \tpopulate: { path: 'organization', select: { unknown: 1 } }, // ❌ not allowed\n * \tsearch: { searchKey: 'x', searchFields: ['unknown'] }, // ❌ not allowed\n * };\n *\n */\n"]}
@@ -76,34 +76,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
76
76
  private baseSchema;
77
77
  constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
78
78
  private createBaseSchema;
79
- getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
79
+ getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
80
80
  getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
81
81
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
82
- }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
82
+ }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
83
83
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
84
- }>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
84
+ }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
85
85
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
86
- }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
87
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
88
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
89
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
90
- }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
91
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
92
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
86
+ }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">>;
93
87
  getIdSchema(): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
94
88
  getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
95
89
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
96
- }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
97
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
98
- }>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
99
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
100
- }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
101
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
102
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
90
+ }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
103
91
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
104
- }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
92
+ }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
105
93
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
106
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
94
+ }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
107
95
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
108
96
  }, "strict", z.ZodTypeAny, {
109
97
  [x: string]: any;
@@ -126,34 +114,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
126
114
  [x: string]: any;
127
115
  }>;
128
116
  getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
129
- BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
117
+ BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
130
118
  EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
131
119
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
132
- }> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
120
+ }> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<T_3[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
133
121
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
134
- }>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
122
+ }> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<T_4[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
135
123
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
136
- }> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<z.objectUtil.extendShape<T, {
137
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
138
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
139
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
140
- }> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
141
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
142
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
124
+ }> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<T_5[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
143
125
  IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
144
126
  UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
145
127
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
146
- }> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
147
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
148
- }>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
149
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
150
- }> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
151
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
152
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
128
+ }> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<T_6[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
153
129
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
154
- }> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<z.objectUtil.extendShape<T, {
130
+ }> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<T_7[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
155
131
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
156
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
132
+ }> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<T_8[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
157
133
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
158
134
  }, "strict", z.ZodTypeAny, {
159
135
  [x: string]: any;
@@ -646,7 +646,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
646
646
  totalPages: number;
647
647
  } | undefined;
648
648
  }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
649
- }>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
649
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
650
650
  success: z.ZodBoolean;
651
651
  message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
652
652
  data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
@@ -684,83 +684,7 @@ export declare const createResponseSchema: <T>(schema: z.ZodSchema<T>) => z.ZodO
684
684
  totalPages: number;
685
685
  } | undefined;
686
686
  }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
687
- }>, any>[k]; } : never, z.baseObjectInputType<{
688
- success: z.ZodBoolean;
689
- message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
690
- data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
691
- metadata: z.ZodOptional<z.ZodObject<{
692
- page: z.ZodNumber;
693
- size: z.ZodNumber;
694
- totalElements: z.ZodNumber;
695
- totalPages: z.ZodNumber;
696
- }, "strip", z.ZodTypeAny, {
697
- page: number;
698
- size: number;
699
- totalElements: number;
700
- totalPages: number;
701
- }, {
702
- page: number;
703
- size: number;
704
- totalElements: number;
705
- totalPages: number;
706
- }>>;
707
- documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
708
- }, "strip", z.ZodTypeAny, {
709
- documents: T[];
710
- metadata?: {
711
- page: number;
712
- size: number;
713
- totalElements: number;
714
- totalPages: number;
715
- } | undefined;
716
- }, {
717
- documents: T[];
718
- metadata?: {
719
- page: number;
720
- size: number;
721
- totalElements: number;
722
- totalPages: number;
723
- } | undefined;
724
- }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
725
- }> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<{
726
- success: z.ZodBoolean;
727
- message: z.ZodString | z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
728
- data: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
729
- metadata: z.ZodOptional<z.ZodObject<{
730
- page: z.ZodNumber;
731
- size: z.ZodNumber;
732
- totalElements: z.ZodNumber;
733
- totalPages: z.ZodNumber;
734
- }, "strip", z.ZodTypeAny, {
735
- page: number;
736
- size: number;
737
- totalElements: number;
738
- totalPages: number;
739
- }, {
740
- page: number;
741
- size: number;
742
- totalElements: number;
743
- totalPages: number;
744
- }>>;
745
- documents: z.ZodArray<z.ZodType<T, z.ZodTypeDef, T>, "many">;
746
- }, "strip", z.ZodTypeAny, {
747
- documents: T[];
748
- metadata?: {
749
- page: number;
750
- size: number;
751
- totalElements: number;
752
- totalPages: number;
753
- } | undefined;
754
- }, {
755
- documents: T[];
756
- metadata?: {
757
- page: number;
758
- size: number;
759
- totalElements: number;
760
- totalPages: number;
761
- } | undefined;
762
- }>, z.ZodType<T, z.ZodTypeDef, T>]>>;
763
- }>[k_1]; } : never>;
687
+ }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
764
688
  export type PaginatedDTO<T> = {
765
689
  metadata: DTO<typeof metadataSchema>;
766
690
  documents: T[];
@@ -1,6 +1,6 @@
1
- import { z } from 'zod';
1
+ import { z, ZodTypeAny } from 'zod';
2
2
  type ReadonlyNonEmptyArray<T> = readonly [T, ...T[]];
3
- export interface FilterSchemaConfig<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {}, TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends ReadonlyNonEmptyArray<string> | [] = []> {
3
+ export interface FilterSchemaConfig<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {}, TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends Record<string, ZodTypeAny> = {}> {
4
4
  selectableFields?: TSelect;
5
5
  populatableFields?: TPopulate;
6
6
  searchableFields?: TSearch;
@@ -19,11 +19,10 @@ export type PopulateObject<TPath extends string, TSelect extends ReadonlyNonEmpt
19
19
  };
20
20
  populate?: never;
21
21
  };
22
- export type FilterDTO<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends ReadonlyNonEmptyArray<string> | [] = [], TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends ReadonlyNonEmptyArray<string> | [] = []> = {
22
+ export type FilterDTO<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends ReadonlyNonEmptyArray<string> | [] = [], TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends Record<string, ZodTypeAny> = {}> = {
23
23
  size?: number;
24
24
  page?: number;
25
25
  sort?: Record<string, 1 | -1>;
26
- query?: TQuery extends ReadonlyNonEmptyArray<string> ? Partial<Record<TQuery[number], any>> : never;
27
26
  select?: TSelect extends ReadonlyNonEmptyArray<string> ? Partial<Record<TSelect[number], 0 | 1>> : never;
28
27
  populate?: TPopulate extends ReadonlyNonEmptyArray<string> ? {
29
28
  [P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;
@@ -34,6 +33,9 @@ export type FilterDTO<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], T
34
33
  searchKey: string;
35
34
  searchFields?: TSearch[number][];
36
35
  } : never;
36
+ query?: {
37
+ [K in keyof TQuery]?: z.infer<TQuery[K]>;
38
+ };
37
39
  };
38
- export declare function createFilterSchema<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {}, TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends ReadonlyNonEmptyArray<string> | [] = []>(config: FilterSchemaConfig<TSelect, TPopulate, TSearch, TQuery>): z.ZodType<FilterDTO<TSelect, keyof TPopulate extends never ? [] : readonly [keyof TPopulate & string, ...(keyof TPopulate & string)[]], TSearch, TQuery>>;
40
+ export declare function createFilterSchema<TSelect extends ReadonlyNonEmptyArray<string> | [] = [], TPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {}, TSearch extends ReadonlyNonEmptyArray<string> | [] = [], TQuery extends Record<string, ZodTypeAny> = {}>(config: FilterSchemaConfig<TSelect, TPopulate, TSearch, TQuery>): z.ZodType<FilterDTO<TSelect, keyof TPopulate extends never ? [] : readonly [keyof TPopulate & string, ...(keyof TPopulate & string)[]], TSearch, TQuery>>;
39
41
  export {};
@@ -58,8 +58,12 @@ function createFilterSchema(config) {
58
58
  })
59
59
  .optional();
60
60
  }
61
- if (queryableFields?.length) {
62
- schemaShape.query = zod_1.z.record(zod_1.z.enum([...queryableFields]), zod_1.z.any()).optional();
61
+ if (queryableFields && Object.keys(queryableFields).length) {
62
+ const queryShape = {};
63
+ for (const key in queryableFields) {
64
+ queryShape[key] = queryableFields[key].optional();
65
+ }
66
+ schemaShape.query = zod_1.z.object(queryShape).optional();
63
67
  }
64
68
  return zod_1.z.object(schemaShape);
65
69
  }
@@ -1 +1 @@
1
- {"version":3,"file":"filter-schema.factory.js","sourceRoot":"/","sources":["utilities/validation/filter-schema.factory.ts"],"names":[],"mappings":";;AAuDA,gDAiGC;AAxJD,6BAAoC;AAqDpC,MAAM,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF,SAAgB,kBAAkB,CAKhC,MAA+D;IAChE,MAAM,EACL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,OAAO,GAAG,GAAG,EACb,WAAW,GAAG,EAAE,GAChB,GAAG,MAAM,CAAC;IAGX,MAAM,YAAY,GAAG,iBAAiB,CAAC,CAAC,CAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAyB,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtG,MAAM,WAAW,GAAwB;QACxC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC;QACpE,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7C,IAAI,EAAE,UAAU,CAAC,QAAQ,EAAE;KAC3B,CAAC;IAGF,IAAI,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAC9B,WAAW,CAAC,MAAM,GAAG,OAAC;aACpB,MAAM,CAAC,OAAC,CAAC,IAAI,CAAC,CAAC,GAAG,gBAAgB,CAA0B,CAAC,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OA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yArray<T> = readonly [T, ...T[]];\n\nexport interface FilterSchemaConfig<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {},\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends ReadonlyNonEmptyArray<string> | [] = [],\n> {\n\tselectableFields?: TSelect;\n\tpopulatableFields?: TPopulate;\n\tsearchableFields?: TSearch;\n\tqueryableFields?: TQuery;\n\tmaxSize?: number;\n\tdefaultSize?: number;\n}\n\nexport type PopulateObject<TPath extends string, TSelect extends ReadonlyNonEmptyArray<string>> = {\n\tpath: TPath;\n\tselect: Partial<Record<TSelect[number], 0 | 1>>;\n\tmatch?: Partial<Record<TSelect[number], any>>;\n\toptions?: { sort?: Record<string, 1 | -1>; limit?: number; skip?: number };\n\tpopulate?: never; // Can be recursively extended\n};\n\nexport type FilterDTO<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends ReadonlyNonEmptyArray<string> | [] = [],\n> = {\n\tsize?: number;\n\tpage?: number;\n\tsort?: Record<string, 1 | -1>;\n\tquery?: TQuery extends ReadonlyNonEmptyArray<string> ? Partial<Record<TQuery[number], any>> : never;\n\tselect?: TSelect extends ReadonlyNonEmptyArray<string> ? Partial<Record<TSelect[number], 0 | 1>> : never;\n\tpopulate?: TPopulate extends ReadonlyNonEmptyArray<string>\n\t\t?\n\t\t\t\t| {\n\t\t\t\t\t\t[P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;\n\t\t\t\t }[TPopulate[number]]\n\t\t\t\t| Array<\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;\n\t\t\t\t\t\t}[TPopulate[number]]\n\t\t\t\t >\n\t\t: never;\n\tsearch?: TSearch extends ReadonlyNonEmptyArray<string>\n\t\t? { searchKey: string; searchFields?: TSearch[number][] }\n\t\t: never;\n};\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nexport function createFilterSchema<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {},\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends ReadonlyNonEmptyArray<string> | [] = [],\n>(config: FilterSchemaConfig<TSelect, TPopulate, TSearch, TQuery>) {\n\tconst {\n\t\tselectableFields,\n\t\tpopulatableFields,\n\t\tsearchableFields,\n\t\tqueryableFields,\n\t\tmaxSize = 100,\n\t\tdefaultSize = 10,\n\t} = config;\n\n\t// Derive populatableFields array from the keys\n\tconst populateKeys = populatableFields ? (Object.keys(populatableFields) as (keyof TPopulate)[]) : [];\n\n\tconst schemaShape: Record<string, any> = {\n\t\tsize: z.number().min(1).max(maxSize).optional().default(defaultSize),\n\t\tpage: z.number().min(1).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t};\n\n\t// Select\n\tif (selectableFields?.length) {\n\t\tschemaShape.select = z\n\t\t\t.record(z.enum([...selectableFields] as [string, ...string[]]), z.union([z.literal(0), z.literal(1)]))\n\t\t\t.optional();\n\t}\n\n\t// Populate\n\tif (populateKeys.length) {\n\t\tconst populateSchemaMap: Record<string, ZodTypeAny> = {};\n\n\t\tfor (const path of populateKeys) {\n\t\t\tconst allowedSelects = populatableFields![path] as ReadonlyNonEmptyArray<string>; // <- assert iterable\n\n\t\t\tpopulateSchemaMap[path as string] = z.lazy(() =>\n\t\t\t\tz.object({\n\t\t\t\t\tpath: z.literal(path as string),\n\t\t\t\t\tselect: z\n\t\t\t\t\t\t.record(\n\t\t\t\t\t\t\tz.enum([...allowedSelects] as [string, ...string[]]),\n\t\t\t\t\t\t\tz.union([z.literal(0), z.literal(1)])\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.optional(),\n\t\t\t\t\tmatch: z.record(z.enum([...allowedSelects] as [string, ...string[]]), z.any()).optional(),\n\t\t\t\t\toptions: z\n\t\t\t\t\t\t.object({\n\t\t\t\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\t\t\t\tlimit: z.number().optional(),\n\t\t\t\t\t\t\tskip: z.number().optional(),\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.optional(),\n\t\t\t\t\tpopulate: z.never(),\n\t\t\t\t})\n\t\t\t) as ZodTypeAny;\n\t\t}\n\n\t\tconst populateSchemas = Object.values(populateSchemaMap);\n\n\t\tif (populateSchemas.length > 0) {\n\t\t\tlet unionSchema: ZodTypeAny;\n\t\t\tif (populateSchemas.length === 1) {\n\t\t\t\tunionSchema = z.union([populateSchemas[0], populateSchemas[0]]);\n\t\t\t} else {\n\t\t\t\tunionSchema = z.union(populateSchemas as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]);\n\t\t\t}\n\t\t\tschemaShape.populate = z\n\t\t\t\t.union([unionSchema, z.array(unionSchema)] as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]])\n\t\t\t\t.optional();\n\t\t}\n\t}\n\n\t// Search\n\tif (searchableFields?.length) {\n\t\tschemaShape.search = z\n\t\t\t.object({\n\t\t\t\tsearchKey: z.string(),\n\t\t\t\tsearchFields: z.array(z.enum([...searchableFields] as [string, ...string[]])).optional(),\n\t\t\t})\n\t\t\t.optional();\n\t}\n\n\t// Query\n\tif (queryableFields?.length) {\n\t\tschemaShape.query = z.record(z.enum([...queryableFields] as [string, ...string[]]), z.any()).optional();\n\t}\n\n\ttype KeysToReadonlyNonEmptyArray<T> = keyof T extends never\n\t\t? []\n\t\t: readonly [keyof T & string, ...(keyof T & string)[]];\n\n\treturn z.object(schemaShape) as z.ZodType<\n\t\tFilterDTO<TSelect, KeysToReadonlyNonEmptyArray<TPopulate>, TSearch, TQuery>\n\t>;\n}\n\n/**\n * @Example\n *\n * const UserFilterSchema = createFilterSchemaStrict({\n * \tselectableFields: ['_id', 'name', 'email', 'role'] as const,\n * \tpopulatableFields: ['organization'] as const,\n * \tpopulateSelectMap: { organization: ['_id', 'name', 'address'] as const },\n * \tsearchableFields: ['name', 'email'] as const,\n * \tqueryableFields: ['role', 'active'] as const,\n * });\n *\n * type UserFilter = z.infer<typeof UserFilterSchema>;\n *\n * ✅ valid\n * const validFilter: UserFilter = {\n * \tselect: { name: 1, email: 1 },\n * \tquery: { role: 'admin', active: true },\n * \tpopulate: { path: 'organization', select: { name: 1 } },\n * \tsearch: { searchKey: 'john', searchFields: ['name', 'email'] },\n * \tpage: 1,\n * \tsize: 20,\n * };\n *\n * ❌ invalid - TypeScript will reject anything outside the rules\n * const invalidFilter: UserFilter = {\n * \tselect: { password: 1 }, // ❌ not allowed\n * \tquery: { status: true }, // ❌ not allowed\n * \tpopulate: { path: 'organization', select: { name: 1 } }, // ❌ not allowed\n * \tsearch: { searchKey: 'x', searchFields: ['unknown'] }, // ❌ not allowed\n * };\n *\n */"]}
1
+ {"version":3,"file":"filter-schema.factory.js","sourceRoot":"/","sources":["utilities/validation/filter-schema.factory.ts"],"names":[],"mappings":";;AAuDA,gDAoGC;AA3JD,6BAAoC;AAqDpC,MAAM,UAAU,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF,SAAgB,kBAAkB,CAKhC,MAA+D;IAChE,MAAM,EACL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,OAAO,GAAG,GAAG,EACb,WAAW,GAAG,EAAE,GAChB,GAAG,MAAM,CAAC;IAEX,MAAM,YAAY,GAAG,iBAAiB,CAAC,CAAC,CAAE,MAAM,CAAC,IA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B,WAAW,CAAC,MAAM,GAAG,OAAC;aACpB,MAAM,CAAC;YACP,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;YACrB,YAAY,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,IAAI,CAAC,CAAC,GAAG,gBAAgB,CAA0B,CAAC,CAAC,CAAC,QAAQ,EAAE;SACxF,CAAC;aACD,QAAQ,EAAE,CAAC;IACd,CAAC;IAGD,IAAI,eAAe,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,EAAE,CAAC;QAC5D,MAAM,UAAU,GAA+B,EAAE,CAAC;QAClD,KAAK,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;YACnC,UAAU,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QACnD,CAAC;QACD,WAAW,CAAC,KAAK,GAAG,OAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;IACrD,CAAC;IAMD,OAAO,OAAC,CAAC,MAAM,CAAC,WAAW,CAE1B,CAAC;AACH,CAAC","sourcesContent":["import { z, ZodTypeAny } from 'zod';\n\ntype ReadonlyNonEmptyArray<T> = readonly [T, ...T[]];\n\nexport interface FilterSchemaConfig<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {},\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends Record<string, ZodTypeAny> = {},\n> {\n\tselectableFields?: TSelect;\n\tpopulatableFields?: TPopulate;\n\tsearchableFields?: TSearch;\n\tqueryableFields?: TQuery;\n\tmaxSize?: number;\n\tdefaultSize?: number;\n}\n\nexport type PopulateObject<TPath extends string, TSelect extends ReadonlyNonEmptyArray<string>> = {\n\tpath: TPath;\n\tselect: Partial<Record<TSelect[number], 0 | 1>>;\n\tmatch?: Partial<Record<TSelect[number], any>>;\n\toptions?: { sort?: Record<string, 1 | -1>; limit?: number; skip?: number };\n\tpopulate?: never;\n};\n\nexport type FilterDTO<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends Record<string, ZodTypeAny> = {},\n> = {\n\tsize?: number;\n\tpage?: number;\n\tsort?: Record<string, 1 | -1>;\n\tselect?: TSelect extends ReadonlyNonEmptyArray<string> ? Partial<Record<TSelect[number], 0 | 1>> : never;\n\tpopulate?: TPopulate extends ReadonlyNonEmptyArray<string>\n\t\t?\n\t\t\t\t| {\n\t\t\t\t\t\t[P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;\n\t\t\t\t }[TPopulate[number]]\n\t\t\t\t| Array<\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[P in TPopulate[number]]: PopulateObject<P, Extract<TSelect, ReadonlyNonEmptyArray<string>>>;\n\t\t\t\t\t\t}[TPopulate[number]]\n\t\t\t\t >\n\t\t: never;\n\tsearch?: TSearch extends ReadonlyNonEmptyArray<string>\n\t\t? { searchKey: string; searchFields?: TSearch[number][] }\n\t\t: never;\n\tquery?: { [K in keyof TQuery]?: z.infer<TQuery[K]> };\n};\n\nconst sortSchema = z.record(z.string(), z.union([z.literal(1), z.literal(-1)]));\n\nexport function createFilterSchema<\n\tTSelect extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTPopulate extends Record<string, ReadonlyNonEmptyArray<string>> | {} = {},\n\tTSearch extends ReadonlyNonEmptyArray<string> | [] = [],\n\tTQuery extends Record<string, ZodTypeAny> = {},\n>(config: FilterSchemaConfig<TSelect, TPopulate, TSearch, TQuery>) {\n\tconst {\n\t\tselectableFields,\n\t\tpopulatableFields,\n\t\tsearchableFields,\n\t\tqueryableFields,\n\t\tmaxSize = 100,\n\t\tdefaultSize = 10,\n\t} = config;\n\n\tconst populateKeys = populatableFields ? (Object.keys(populatableFields) as (keyof TPopulate)[]) : [];\n\n\tconst schemaShape: Record<string, any> = {\n\t\tsize: z.number().min(1).max(maxSize).optional().default(defaultSize),\n\t\tpage: z.number().min(1).optional().default(1),\n\t\tsort: sortSchema.optional(),\n\t};\n\n\t// Select\n\tif (selectableFields?.length) {\n\t\tschemaShape.select = z\n\t\t\t.record(z.enum([...selectableFields] as [string, ...string[]]), z.union([z.literal(0), z.literal(1)]))\n\t\t\t.optional();\n\t}\n\n\t// Populate\n\tif (populateKeys.length) {\n\t\tconst populateSchemaMap: Record<string, ZodTypeAny> = {};\n\n\t\tfor (const path of populateKeys) {\n\t\t\tconst allowedSelects = populatableFields![path] as ReadonlyNonEmptyArray<string>;\n\n\t\t\tpopulateSchemaMap[path as string] = z.lazy(() =>\n\t\t\t\tz.object({\n\t\t\t\t\tpath: z.literal(path as string),\n\t\t\t\t\tselect: z\n\t\t\t\t\t\t.record(\n\t\t\t\t\t\t\tz.enum([...allowedSelects] as [string, ...string[]]),\n\t\t\t\t\t\t\tz.union([z.literal(0), z.literal(1)])\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.optional(),\n\t\t\t\t\tmatch: z.record(z.enum([...allowedSelects] as [string, ...string[]]), z.any()).optional(),\n\t\t\t\t\toptions: z\n\t\t\t\t\t\t.object({\n\t\t\t\t\t\t\tsort: sortSchema.optional(),\n\t\t\t\t\t\t\tlimit: z.number().optional(),\n\t\t\t\t\t\t\tskip: z.number().optional(),\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.optional(),\n\t\t\t\t\tpopulate: z.never(),\n\t\t\t\t})\n\t\t\t) as ZodTypeAny;\n\t\t}\n\n\t\tconst populateSchemas = Object.values(populateSchemaMap);\n\n\t\tif (populateSchemas.length > 0) {\n\t\t\tlet unionSchema: ZodTypeAny;\n\t\t\tif (populateSchemas.length === 1) {\n\t\t\t\tunionSchema = z.union([populateSchemas[0], populateSchemas[0]]);\n\t\t\t} else {\n\t\t\t\tunionSchema = z.union(populateSchemas as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]]);\n\t\t\t}\n\t\t\tschemaShape.populate = z\n\t\t\t\t.union([unionSchema, z.array(unionSchema)] as [ZodTypeAny, ZodTypeAny, ...ZodTypeAny[]])\n\t\t\t\t.optional();\n\t\t}\n\t}\n\n\t// Search\n\tif (searchableFields?.length) {\n\t\tschemaShape.search = z\n\t\t\t.object({\n\t\t\t\tsearchKey: z.string(),\n\t\t\t\tsearchFields: z.array(z.enum([...searchableFields] as [string, ...string[]])).optional(),\n\t\t\t})\n\t\t\t.optional();\n\t}\n\n\t// Query\n\tif (queryableFields && Object.keys(queryableFields).length) {\n\t\tconst queryShape: Record<string, ZodTypeAny> = {};\n\t\tfor (const key in queryableFields) {\n\t\t\tqueryShape[key] = queryableFields[key].optional();\n\t\t}\n\t\tschemaShape.query = z.object(queryShape).optional();\n\t}\n\n\ttype KeysToReadonlyNonEmptyArray<T> = keyof T extends never\n\t\t? []\n\t\t: readonly [keyof T & string, ...(keyof T & string)[]];\n\n\treturn z.object(schemaShape) as z.ZodType<\n\t\tFilterDTO<TSelect, KeysToReadonlyNonEmptyArray<TPopulate>, TSearch, TQuery>\n\t>;\n}\n\n/**\n *\n *\n * const UserFilterSchema = createFilterSchema({\n * \tselectableFields: ['_id', 'name', 'email', 'role'] as const,\n * \tpopulatableFields: { organization: ['_id', 'name', 'address'] as const },\n * \tsearchableFields: ['name', 'email'] as const,\n * \tqueryableFields: {\n * \t\trole: z.string(),\n * \t\tactive: z.boolean(),\n * \t},\n * });\n *\n * type UserFilter = z.infer<typeof UserFilterSchema>;\n *\n * const validFilter: UserFilter = {\n * \tselect: { name: 1, email: 1 },\n * \tquery: { role: 'admin', active: true },\n * \tpopulate: { path: 'organization', select: { name: 1 } },\n * \tsearch: { searchKey: 'john', searchFields: ['name', 'email'] },\n * \tpage: 1,\n * \tsize: 20,\n * };\n *\n * ❌ TypeScript will reject invalid assignments\n * const invalidFilter: UserFilter = {\n * \tselect: { password: 1 }, // ❌ not allowed\n * \tquery: { role: 123, active: 'yes' }, // ❌ not allowed\n * \tpopulate: { path: 'organization', select: { unknown: 1 } }, // ❌ not allowed\n * \tsearch: { searchKey: 'x', searchFields: ['unknown'] }, // ❌ not allowed\n * };\n *\n */\n"]}
@@ -76,34 +76,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
76
76
  private baseSchema;
77
77
  constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
78
78
  private createBaseSchema;
79
- getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
79
+ getBaseSchema(): z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
80
80
  getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
81
81
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
82
- }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
82
+ }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
83
83
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
84
- }>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
84
+ }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
85
85
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
86
- }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
87
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
88
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
89
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
90
- }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
91
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
92
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
86
+ }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">>;
93
87
  getIdSchema(): z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
94
88
  getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
95
89
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
96
- }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
97
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
98
- }>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
99
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
100
- }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
101
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
102
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
90
+ }> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
103
91
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
104
- }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
92
+ }> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<T_2[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
105
93
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
106
- }>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
94
+ }> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<T_3[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
107
95
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
108
96
  }, "strict", z.ZodTypeAny, {
109
97
  [x: string]: any;
@@ -126,34 +114,22 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
126
114
  [x: string]: any;
127
115
  }>;
128
116
  getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
129
- BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any>[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: z.baseObjectInputType<T>[k_1]; } : never>;
117
+ BaseSchema: z.ZodObject<T, "strict", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<T>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<T> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
130
118
  EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
131
119
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
132
- }> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
120
+ }> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<T_3[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
133
121
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
134
- }>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
122
+ }> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<T_4[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
135
123
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
136
- }> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<z.objectUtil.extendShape<T, {
137
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
138
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
139
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
140
- }> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
141
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
142
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
124
+ }> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<T_5[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
143
125
  IdSchema: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
144
126
  UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
145
127
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
146
- }> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
147
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
148
- }>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
149
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
150
- }> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
151
- _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
152
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
128
+ }> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<T_6[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
153
129
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
154
- }> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<z.objectUtil.extendShape<T, {
130
+ }> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<T_7[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
155
131
  _id: z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, mongoose.Types.ObjectId, string>, z.ZodType<mongoose.Types.ObjectId, z.ZodTypeDef, mongoose.Types.ObjectId>]>;
156
- }>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
132
+ }> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<T_8[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
157
133
  [x: string]: z.ZodOptional<z.ZodTypeAny>;
158
134
  }, "strict", z.ZodTypeAny, {
159
135
  [x: string]: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyxa.ai/core",
3
- "version": "1.1.55",
3
+ "version": "1.1.57",
4
4
  "description": "The Core system of the Lyxa services.",
5
5
  "author": "elie <42282499+Internalizable@users.noreply.github.com>",
6
6
  "license": "MIT",