@lyxa.ai/core 1.0.60 → 1.0.61
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.
- package/dist/libraries/mongo/models/brand.model.js +2 -2
- package/dist/libraries/mongo/models/brand.model.js.map +1 -1
- package/dist/libraries/mongo/models/product-marketing.model.d.ts +1 -2
- package/dist/libraries/mongo/models/product-marketing.model.js +2 -7
- package/dist/libraries/mongo/models/product-marketing.model.js.map +1 -1
- package/dist/libraries/mongo/models/tag.model.d.ts +2 -2
- package/dist/libraries/mongo/models/tag.model.js +2 -2
- package/dist/libraries/mongo/models/tag.model.js.map +1 -1
- package/dist/utilities/error-handler.js +1 -1
- package/dist/utilities/error-handler.js.map +1 -1
- package/dist/utilities/validation/common-validation.d.ts +7 -7
- package/dist/utilities/validation/global-validation.d.ts +22 -54
- package/dist/utilities/validation/global-validation.js +6 -5
- package/dist/utilities/validation/global-validation.js.map +1 -1
- package/package.json +1 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/libraries/auth/index.d.ts.map +0 -1
- package/dist/libraries/auth/refreshtoken.d.ts.map +0 -1
- package/dist/libraries/auth/repository.d.ts.map +0 -1
- package/dist/libraries/configuration/index.d.ts.map +0 -1
- package/dist/libraries/configuration/types/EnvironmentConfigurationType.d.ts.map +0 -1
- package/dist/libraries/dispatcher/index.d.ts.map +0 -1
- package/dist/libraries/event/BaseEvent.d.ts.map +0 -1
- package/dist/libraries/event/decorators/metadata.d.ts.map +0 -1
- package/dist/libraries/event/decorators/subscribe.d.ts.map +0 -1
- package/dist/libraries/event/index.d.ts.map +0 -1
- package/dist/libraries/event/registry/SubscriptionRegistry.d.ts.map +0 -1
- package/dist/libraries/event/test/OrderCreationEvent.d.ts.map +0 -1
- package/dist/libraries/firebase/index.d.ts.map +0 -1
- package/dist/libraries/index.d.ts.map +0 -1
- package/dist/libraries/logger/index.d.ts.map +0 -1
- package/dist/libraries/map/index.d.ts.map +0 -1
- package/dist/libraries/map/interfaces/IMapService.d.ts.map +0 -1
- package/dist/libraries/map/mapService.d.ts.map +0 -1
- package/dist/libraries/map/providers/google-maps.d.ts.map +0 -1
- package/dist/libraries/map/providers/index.d.ts.map +0 -1
- package/dist/libraries/mongo/index.d.ts.map +0 -1
- package/dist/libraries/mongo/models/activity-log.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/admin-access-control.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/admin.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/app-screen-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/attribute.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/banner.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/base/base-coupon.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/base/base-review.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/bob-finance.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/brand.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/card.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/cart-participant.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/cart.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/category.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/core-auth-identity.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/core-user.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/counter.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/coupon.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/deal-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/dish.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/duration.model.d.ts +0 -4
- package/dist/libraries/mongo/models/duration.model.js +0 -27
- package/dist/libraries/mongo/models/duration.model.js.map +0 -1
- package/dist/libraries/mongo/models/embedded/addon.model.d.ts +0 -8
- package/dist/libraries/mongo/models/embedded/addon.model.js +0 -34
- package/dist/libraries/mongo/models/embedded/addon.model.js.map +0 -1
- package/dist/libraries/mongo/models/embedded/attribute-item.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/attribute-map.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/business-development-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/charge-setting.model.d.ts +0 -14
- package/dist/libraries/mongo/models/embedded/charge-setting.model.js +0 -60
- package/dist/libraries/mongo/models/embedded/charge-setting.model.js.map +0 -1
- package/dist/libraries/mongo/models/embedded/charge.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/courier-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/currency-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/currency.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/delivery-charge-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/delivery-info.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/featured-item.mode.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/line-item-attribute.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/marketing-cut.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/order-cancel.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/order-pricing.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/otp-fields.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/package.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/parent-document.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/payment-attempt.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/payment-infromation.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/payout-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/portion.model.d.ts +0 -5
- package/dist/libraries/mongo/models/embedded/portion.model.js +0 -32
- package/dist/libraries/mongo/models/embedded/portion.model.js.map +0 -1
- package/dist/libraries/mongo/models/embedded/price-breakdown.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/price.model.d.ts +0 -5
- package/dist/libraries/mongo/models/embedded/price.model.js +0 -32
- package/dist/libraries/mongo/models/embedded/price.model.js.map +0 -1
- package/dist/libraries/mongo/models/embedded/product-nutrition.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/profit.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/referral-discount-config.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/rider-equipment.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/rider-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/service-fee-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/shop-document.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/status-timeline.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/subscription-summary.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/vat.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/embedded/zone-geometry.mode.d.ts.map +0 -1
- package/dist/libraries/mongo/models/faq.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/favourite.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/featured-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/filter-container.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/finance-settlement.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/gallery.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/index.d.ts.map +0 -1
- package/dist/libraries/mongo/models/line-item.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/list-container.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/loyalty-point-category.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/loyalty-point-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/marketing.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/meal-plan.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/notification.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/nutrition.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/order-delivery.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/order-finance.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/order-payment.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/order.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/parent.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/payout.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/product-marketing.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/product.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/areeba-card.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/buy1-get1-marketing.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/core-apple-auth-identity.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/core-email-auth-identity.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/core-google-auth-identity.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/core-phone-auth-identity.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/courier-order-finance.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/courier-order.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/custom-coupon.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/discount-marketing.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/featured-marketing.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/free-delivery-marketing.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/global-coupon.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/individual-store-coupon.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/individual-user-coupon.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/loyalty-point-marketing.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/punch-marketing.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/referral-code-coupon.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/referral-reward-coupon.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/regular-order-finance.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/providers/regular-order.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/punch-marketing-history.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/rating-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/referral-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/request-area.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/rider-review.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/rider-timeout.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/rider-tracking.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/rider.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/role.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/shared/address.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/shared/duration.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/shared/geo-location.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/shared/work-hour.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/shop-access-control.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/shop-category.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/shop-meal-plan.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/shop-product.model.d.ts +0 -25
- package/dist/libraries/mongo/models/shop-product.model.js +0 -102
- package/dist/libraries/mongo/models/shop-product.model.js.map +0 -1
- package/dist/libraries/mongo/models/shop-review.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/shop.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/subscription-setting.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/subscription.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/tag.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/transaction.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/user.model.d.ts.map +0 -1
- package/dist/libraries/mongo/models/work-hour.model.d.ts +0 -21
- package/dist/libraries/mongo/models/work-hour.model.js +0 -76
- package/dist/libraries/mongo/models/work-hour.model.js.map +0 -1
- package/dist/libraries/mongo/models/zone.model.d.ts.map +0 -1
- package/dist/libraries/mongo/plugins/soft-delete-plugin.d.ts.map +0 -1
- package/dist/libraries/redis/index.d.ts.map +0 -1
- package/dist/libraries/secrets/index.d.ts.map +0 -1
- package/dist/libraries/trpc/context.d.ts.map +0 -1
- package/dist/libraries/trpc/index.d.ts.map +0 -1
- package/dist/libraries/trpc/middlewares/auth.d.ts.map +0 -1
- package/dist/libraries/trpc/middlewares/cors.d.ts.map +0 -1
- package/dist/libraries/trpc/middlewares/phone-verified.d.ts.map +0 -1
- package/dist/libraries/twilio/index.d.ts.map +0 -1
- package/dist/libraries/upload/index.d.ts.map +0 -1
- package/dist/utilities/common/password.d.ts.map +0 -1
- package/dist/utilities/common/week.d.ts.map +0 -1
- package/dist/utilities/enum.d.ts.map +0 -1
- package/dist/utilities/error-handler.d.ts.map +0 -1
- package/dist/utilities/error-middleware.d.ts.map +0 -1
- package/dist/utilities/pagination.d.ts.map +0 -1
- package/dist/utilities/response.d.ts.map +0 -1
- package/dist/utilities/search.d.ts.map +0 -1
- package/dist/utilities/transformers.d.ts.map +0 -1
- package/dist/utilities/validation/common-validation.d.ts.map +0 -1
- package/dist/utilities/validation/global-validation.d.ts.map +0 -1
- package/dist/utilities/validation/index.d.ts.map +0 -1
|
@@ -18,11 +18,11 @@ let Brand = class Brand extends defaultClasses_1.TimeStamps {
|
|
|
18
18
|
};
|
|
19
19
|
exports.Brand = Brand;
|
|
20
20
|
__decorate([
|
|
21
|
-
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
21
|
+
(0, typegoose_1.prop)({ required: true, type: String, trim: true, maxlength: 50 }),
|
|
22
22
|
__metadata("design:type", String)
|
|
23
23
|
], Brand.prototype, "name", void 0);
|
|
24
24
|
__decorate([
|
|
25
|
-
(0, typegoose_1.prop)({ type: String }),
|
|
25
|
+
(0, typegoose_1.prop)({ type: String, maxlength: 250 }),
|
|
26
26
|
__metadata("design:type", String)
|
|
27
27
|
], Brand.prototype, "description", void 0);
|
|
28
28
|
exports.Brand = Brand = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brand.model.js","sourceRoot":"/","sources":["libraries/mongo/models/brand.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiE;AACjE,4EAAqE;AAI9D,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQ,2BAAU;IAE7B,IAAI,CAAU;IAGd,WAAW,CAAU;CAC5B,CAAA;AANY,sBAAK;AAEV;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;
|
|
1
|
+
{"version":3,"file":"brand.model.js","sourceRoot":"/","sources":["libraries/mongo/models/brand.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiE;AACjE,4EAAqE;AAI9D,IAAM,KAAK,GAAX,MAAM,KAAM,SAAQ,2BAAU;IAE7B,IAAI,CAAU;IAGd,WAAW,CAAU;CAC5B,CAAA;AANY,sBAAK;AAEV;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;;mCAC7C;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;;0CACX;gBALhB,KAAK;IAFjB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,CAAC;IACzD,IAAA,iBAAK,EAAC,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;GACtE,KAAK,CAMjB","sourcesContent":["import { Index, modelOptions, prop } from '@typegoose/typegoose';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\n\n@modelOptions({ schemaOptions: { collection: 'brands' } })\n@Index({ name: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\nexport class Brand extends TimeStamps {\n\t@prop({ required: true, type: String, trim: true, maxlength: 50 })\n\tpublic name!: string;\n\n\t@prop({ type: String, maxlength: 250 })\n\tpublic description?: string;\n}\n"]}
|
|
@@ -19,7 +19,6 @@ let ProductMarketing = class ProductMarketing {
|
|
|
19
19
|
product;
|
|
20
20
|
marketing;
|
|
21
21
|
loyaltyPointCategory;
|
|
22
|
-
isBuy1Get1;
|
|
23
22
|
valueType;
|
|
24
23
|
value;
|
|
25
24
|
};
|
|
@@ -37,15 +36,11 @@ __decorate([
|
|
|
37
36
|
__metadata("design:type", Object)
|
|
38
37
|
], ProductMarketing.prototype, "loyaltyPointCategory", void 0);
|
|
39
38
|
__decorate([
|
|
40
|
-
(0, typegoose_1.prop)({ type:
|
|
41
|
-
__metadata("design:type", Boolean)
|
|
42
|
-
], ProductMarketing.prototype, "isBuy1Get1", void 0);
|
|
43
|
-
__decorate([
|
|
44
|
-
(0, typegoose_1.prop)({ type: String, enum: enum_1.ValueType }),
|
|
39
|
+
(0, typegoose_1.prop)({ type: String, enum: enum_1.ValueType, default: enum_1.ValueType.PERCENTAGE }),
|
|
45
40
|
__metadata("design:type", String)
|
|
46
41
|
], ProductMarketing.prototype, "valueType", void 0);
|
|
47
42
|
__decorate([
|
|
48
|
-
(0, typegoose_1.prop)({ type: Number }),
|
|
43
|
+
(0, typegoose_1.prop)({ required: true, type: Number }),
|
|
49
44
|
__metadata("design:type", Number)
|
|
50
45
|
], ProductMarketing.prototype, "value", void 0);
|
|
51
46
|
exports.ProductMarketing = ProductMarketing = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/product-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,kDAAoD;AACpD,iFAAsE;AACtE,uDAA8C;AAC9C,mDAA0C;AAInC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAErB,OAAO,CAAgB;IAGvB,SAAS,CAAkB;IAG3B,oBAAoB,CAA6B;IAGjD,
|
|
1
|
+
{"version":3,"file":"product-marketing.model.js","sourceRoot":"/","sources":["libraries/mongo/models/product-marketing.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,kDAAoD;AACpD,iFAAsE;AACtE,uDAA8C;AAC9C,mDAA0C;AAInC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAErB,OAAO,CAAgB;IAGvB,SAAS,CAAkB;IAG3B,oBAAoB,CAA6B;IAGjD,SAAS,CAAa;IAGtB,KAAK,CAAU;CACtB,CAAA;AAfY,4CAAgB;AAErB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,uBAAO,EAAE,CAAC;;iDACf;AAGvB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,2BAAS,EAAE,CAAC;;mDACb;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,mDAAoB,EAAE,CAAC;;8DACc;AAGjD;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAS,EAAE,OAAO,EAAE,gBAAS,CAAC,UAAU,EAAE,CAAC;;mDAC1C;AAGtB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;+CACjB;2BAdV,gBAAgB;IAD5B,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,EAAE,CAAC;GACxD,gBAAgB,CAe5B","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { ValueType } from '../../../utilities/enum';\nimport { LoyaltyPointCategory } from './loyalty-point-category.model';\nimport { Marketing } from './marketing.model';\nimport { Product } from './product.model';\nimport { MicroPercentRange } from 'firebase-admin/lib/remote-config/remote-config-api';\n\n@modelOptions({ schemaOptions: { collection: 'productMarketings' } })\nexport class ProductMarketing {\n\t@prop({ required: true, ref: () => Product })\n\tpublic product!: Ref<Product>;\n\n\t@prop({ required: true, ref: () => Marketing })\n\tpublic marketing!: Ref<Marketing>;\n\n\t@prop({ ref: () => LoyaltyPointCategory })\n\tpublic loyaltyPointCategory?: Ref<LoyaltyPointCategory>;\n\n\t@prop({ type: String, enum: ValueType, default: ValueType.PERCENTAGE })\n\tpublic valueType?: ValueType;\n\n\t@prop({ required: true, type: Number })\n\tpublic value!: number;\n}\n\n"]}
|
|
@@ -23,11 +23,11 @@ let Tag = class Tag {
|
|
|
23
23
|
};
|
|
24
24
|
exports.Tag = Tag;
|
|
25
25
|
__decorate([
|
|
26
|
-
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
26
|
+
(0, typegoose_1.prop)({ required: true, type: String, trim: true, maxlength: 30 }),
|
|
27
27
|
__metadata("design:type", String)
|
|
28
28
|
], Tag.prototype, "name", void 0);
|
|
29
29
|
__decorate([
|
|
30
|
-
(0, typegoose_1.prop)({ type: String }),
|
|
30
|
+
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
31
31
|
__metadata("design:type", String)
|
|
32
32
|
], Tag.prototype, "image", void 0);
|
|
33
33
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tag.model.js","sourceRoot":"/","sources":["libraries/mongo/models/tag.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,kDAA2D;AAC3D,wBAA6B;AAsGtB,IAAM,GAAG,GAAT,MAAM,GAAG;IAER,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,QAAQ,CAAY;IAGpB,MAAM,CAAU;IAGhB,SAAS,CAAW;IAGpB,YAAY,CAAU;CAC7B,CAAA;AAlBY,kBAAG;AAER;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;
|
|
1
|
+
{"version":3,"file":"tag.model.js","sourceRoot":"/","sources":["libraries/mongo/models/tag.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAsE;AACtE,kDAA2D;AAC3D,wBAA6B;AAsGtB,IAAM,GAAG,GAAT,MAAM,GAAG;IAER,IAAI,CAAU;IAGd,KAAK,CAAU;IAGf,QAAQ,CAAY;IAGpB,MAAM,CAAU;IAGhB,SAAS,CAAW;IAGpB,YAAY,CAAU;CAC7B,CAAA;AAlBY,kBAAG;AAER;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;;iCAC7C;AAGd;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kCACjB;AAGf;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,eAAQ,EAAE,CAAC;;qCAC5B;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAM,EAAE,OAAO,EAAE,aAAM,CAAC,MAAM,EAAE,CAAC;;mCACtC;AAGhB;IADN,IAA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AI,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,aAAM,CAAC,MAAM,EAAE,CAAC;gBAEzC,MAAM,eAAe,GAAG,MAAM,WAAQ,CAAC,SAAS,CAA8B;oBAC7E;wBACC,MAAM,EAAE;4BACP,QAAQ,EAAE,GAAG,CAAC,QAAQ;4BACtB,MAAM,EAAE,aAAM,CAAC,MAAM;4BACrB,SAAS,EAAE,IAAI;yBACf;qBACD;oBACD;wBACC,MAAM,EAAE;4BACP,GAAG,EAAE,IAAI;4BACT,eAAe,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;yBAC1C;qBACD;iBACD,CAAC,CAAC,IAAI,EAAE,CAAC;gBAGV,MAAM,CAAC,YAAY,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,eAAe,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBAGtE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACxB,CAAC;QACF,CAAC;QAED,IAAI,EAAE,CAAC;IACR,CAAC,CAAC;GACW,GAAG,CAkBf","sourcesContent":["import { Index, modelOptions, pre, prop } from '@typegoose/typegoose';\nimport { ItemType, Status } from '../../../utilities/enum';\nimport { TagModel } from '.';\nimport { Query } from 'mongoose';\n\n@modelOptions({ schemaOptions: { collection: 'tags' } })\n@Index({ name: 1, itemType: 1 }, { unique: true, partialFilterExpression: { deletedAt: null } })\n@Index({ itemType: 1, deletedAt: 1 })\n@pre<Tag>('save', async function (next) {\n\t// Only set sortingOrder if it's a new document or sortingOrder is not set\n\tif (this.isNew || typeof this.sortingOrder === 'undefined') {\n\t\ttry {\n\t\t\t// Find the maximum sortingOrder for tags with the same itemType that aren't deleted\n\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\titemType: this.itemType,\n\t\t\t\t\t\tstatus: Status.ACTIVE,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the new sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t} catch (error) {\n\t\t\treturn next(error as Error);\n\t\t}\n\t}\n\n\t// Add this code to handle status change from inactive to active\n\tif (this.isModified('status') && this.status === Status.ACTIVE) {\n\t\t// Check if status was previously inactive\n\t\tconst original = await TagModel.findById(this._id);\n\t\tif (original && original.status !== Status.ACTIVE) {\n\t\t\ttry {\n\t\t\t\t// Find the maximum sortingOrder for active tags with the same itemType\n\t\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t\t{\n\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\titemType: this.itemType,\n\t\t\t\t\t\t\tstatus: Status.ACTIVE,\n\t\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t]).exec();\n\n\t\t\t\t// Set the sortingOrder to max + 1 (or 0 if no items found)\n\t\t\t\tthis.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\t\t\t} catch (error) {\n\t\t\t\treturn next(error as Error);\n\t\t\t}\n\t\t}\n\t}\n\n\tnext();\n})\n@pre<Tag>('findOneAndUpdate', async function (this: Query<any, Tag>, next) {\n\tconst update = this.getUpdate() as any;\n\n\tif (update?.status === Status.ACTIVE) {\n\t\t// Get current document (before update)\n\t\tconst tag = await this.model.findOne(this.getQuery());\n\n\t\tif (tag && tag.status !== Status.ACTIVE) {\n\t\t\t// Find the maximum sortingOrder for active tags with the same itemType\n\t\t\tconst maxSortingOrder = await TagModel.aggregate<{ maxSortingOrder: number }>([\n\t\t\t\t{\n\t\t\t\t\t$match: {\n\t\t\t\t\t\titemType: tag.itemType,\n\t\t\t\t\t\tstatus: Status.ACTIVE,\n\t\t\t\t\t\tdeletedAt: null,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\t$group: {\n\t\t\t\t\t\t_id: null,\n\t\t\t\t\t\tmaxSortingOrder: { $max: '$sortingOrder' },\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t]).exec();\n\n\t\t\t// Set the sortingOrder to max + 1 (or 0 if no items found)\n\t\t\tupdate.sortingOrder = (maxSortingOrder[0]?.maxSortingOrder ?? -1) + 1;\n\n\t\t\t// Inject the new sortingOrder into the update\n\t\t\tthis.setUpdate(update);\n\t\t}\n\t}\n\n\tnext();\n})\nexport class Tag {\n\t@prop({ required: true, type: String, trim: true, maxlength: 30 })\n\tpublic name!: string;\n\n\t@prop({ required: true, type: String })\n\tpublic image!: string;\n\n\t@prop({ required: true, type: String, enum: ItemType })\n\tpublic itemType!: ItemType;\n\n\t@prop({ type: String, enum: Status, default: Status.ACTIVE })\n\tpublic status?: Status;\n\n\t@prop({ type: Boolean, default: true })\n\tpublic isVisible?: boolean;\n\n\t@prop({ type: Number })\n\tpublic sortingOrder?: number;\n}\n"]}
|
|
@@ -11,7 +11,7 @@ class ErrorHandler {
|
|
|
11
11
|
retryableErrors: new Set(['ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'EPIPE']),
|
|
12
12
|
};
|
|
13
13
|
static MONGO_ERROR_CODES = {
|
|
14
|
-
11000: { code: 'CONFLICT', message: '
|
|
14
|
+
11000: { code: 'CONFLICT', message: 'A record with this value already exists.' },
|
|
15
15
|
11001: { code: 'CONFLICT', message: 'Duplicate key error on index update.' },
|
|
16
16
|
121: { code: 'BAD_REQUEST', message: 'Document validation failed.' },
|
|
17
17
|
7: { code: 'INTERNAL_SERVER_ERROR', message: 'Not primary - database is in recovery mode.' },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"/","sources":["utilities/error-handler.ts"],"names":[],"mappings":";;;AAKA,yCAAyC;AACzC,qCAA0E;AAC1E,6BAA+B;AAM/B,MAAa,YAAY;IAKhB,MAAM,CAAU,MAAM,GAAG;QAEhC,eAAe,EAAE,IAAI;QAErB,kBAAkB,EAAE,EAAE;QAEtB,eAAe,EAAE,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;KAC9E,CAAC;IAMM,MAAM,CAAU,iBAAiB,GAMrC;QACH,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,+DAA+D,EAAE;QACrG,KAAK,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,sCAAsC,EAAE;QAC5E,GAAG,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,6BAA6B,EAAE;QACpE,CAAC,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,6CAA6C,EAAE;QAC5F,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,mCAAmC,EAAE;QACvE,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,6BAA6B,EAAE;QAC/D,GAAG,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,0DAA0D,EAAE;QACjG,EAAE,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE,OAAO,EAAE,2BAA2B,EAAE;KAC3E,CAAC;IAQM,MAAM,CAAC,QAAQ,CAAC,KAAc,EAAE,UAAmC,EAAE;QAC5E,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,eAAe;YAAE,OAAO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C,UAAU,EAAG,KAA0B,CAAC,UAAU;iBAClD;aACD,CAAC;QACH,CAAC;QAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC5B,OAAO;gBACN,IAAI,EAAE,WAAW;gBACjB,aAAa,EAAE,KAAK;gBACpB,OAAO,EAAE;oBACR,IAAI,EAAE,KAAK,CAAC,IAAI;oBAChB,IAAI,EAAG,KAA+B,CAAC,IAAI;iBAC3C;aACD,CAAC;QACH,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IACvD,CAAC;;AAtUF,oCAuUC","sourcesContent":["/**\n * @fileoverview Error handling utility for TRPC and MongoDB operations.\n * Provides centralized error handling, logging, and retry mechanisms.\n */\n\nimport { TRPCError } from '@trpc/server';\nimport { MongoServerError, MongoError, MongoNetworkError } from 'mongodb';\nimport { ZodError } from 'zod';\n\n/**\n * A utility class for handling various types of errors in a TRPC-MongoDB application.\n * Provides error transformation, logging, and retry mechanisms.\n */\nexport class ErrorHandler {\n\t/**\n\t * Configuration options for error handling behavior\n\t * @private\n\t */\n\tprivate static readonly CONFIG = {\n\t\t/** Whether to log errors to console */\n\t\tshouldLogErrors: true,\n\t\t/** Maximum number of stack trace lines to include in logs */\n\t\tmaxStackTraceLines: 10,\n\t\t/** Set of error codes that are considered retryable */\n\t\tretryableErrors: new Set(['ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'EPIPE']),\n\t};\n\n\t/**\n\t * Mapping of MongoDB error codes to TRPC error types and messages\n\t * @private\n\t */\n\tprivate static readonly MONGO_ERROR_CODES: Record<\n\t\tnumber,\n\t\t{\n\t\t\tcode: TRPCError['code'];\n\t\t\tmessage: string;\n\t\t}\n\t> = {\n\t\t11000: { code: 'CONFLICT', message: 'Duplicate key error: A record with this value already exists.' },\n\t\t11001: { code: 'CONFLICT', message: 'Duplicate key error on index update.' },\n\t\t121: { code: 'BAD_REQUEST', message: 'Document validation failed.' },\n\t\t7: { code: 'INTERNAL_SERVER_ERROR', message: 'Not primary - database is in recovery mode.' },\n\t\t89: { code: 'FORBIDDEN', message: 'Unauthorized operation attempted.' },\n\t\t91: { code: 'TIMEOUT', message: 'Operation timeout exceeded.' },\n\t\t189: { code: 'BAD_REQUEST', message: 'Invalid modification - document would exceed size limit.' },\n\t\t50: { code: 'INTERNAL_SERVER_ERROR', message: 'Database execution error.' },\n\t};\n\n\t/**\n\t * Logs error information with metadata and stack trace\n\t * @private\n\t * @param error - The error to log\n\t * @param context - Additional context information for the error\n\t */\n\tprivate static logError(error: unknown, context: Record<string, unknown> = {}): void {\n\t\tif (!this.CONFIG.shouldLogErrors) return;\n\n\t\tconst errorMeta = this.extractErrorMetadata(error);\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tconst logData = {\n\t\t\ttimestamp,\n\t\t\ttype: errorMeta.type,\n\t\t\tmessage: error instanceof Error ? error.message : 'Unknown error',\n\t\t\tstack:\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? error.stack?.split('\\n').slice(0, this.CONFIG.maxStackTraceLines).join('\\n')\n\t\t\t\t\t: undefined,\n\t\t\tcontext,\n\t\t\tmetadata: errorMeta,\n\t\t};\n\n\t\tconsole.error('[ErrorHandler]:', JSON.stringify(logData, null, 2));\n\t}\n\n\t/**\n\t * Main error handling method that transforms various error types into TRPC errors\n\t * @param error - The error to handle\n\t * @param customMessage - Optional custom error message\n\t * @param context - Additional context information\n\t * @throws {TRPCError} Transformed error with appropriate error code and message\n\t */\n\tpublic static handleError(\n\t\terror: unknown,\n\t\tcustomMessage = 'An unexpected error occurred',\n\t\tcontext: Record<string, unknown> = {}\n\t): never {\n\t\tthis.logError(error, context);\n\n\t\tif (error instanceof TRPCError) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (error instanceof ZodError) {\n\t\t\ttry {\n\t\t\t\tconsole.log('ZodError:', error.flatten());\n\t\t\t\tconst formatted = error.errors.map(e => ({\n\t\t\t\t\tfield: e.path.join('.'),\n\t\t\t\t\tmessage: e.message,\n\t\t\t\t}));\n\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'BAD_REQUEST',\n\t\t\t\t\tmessage: 'Validation error',\n\t\t\t\t\tcause: formatted,\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\t// Handle any issues with flattening or logging\n\t\t\t\tconsole.error('Error while processing ZodError:', err);\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\t\tmessage: 'Error processing validation error',\n\t\t\t\t\tcause: err,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (error instanceof MongoNetworkError) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Database connection error',\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\n\t\tif (this.isMongoError(error)) {\n\t\t\tthrow this.createMongoTRPCError(error);\n\t\t}\n\n\t\tif (error instanceof Error) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: this.mapNodeErrorCode(error),\n\t\t\t\tmessage: error.message || customMessage,\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\n\t\tthrow new TRPCError({\n\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\tmessage: customMessage,\n\t\t\tcause: error,\n\t\t});\n\t}\n\n\t/**\n\t * Type guard to check if an error is a MongoDB error\n\t * @private\n\t * @param error - The error to check\n\t * @returns True if the error is a MongoDB error\n\t */\n\tprivate static isMongoError(error: unknown): error is MongoServerError {\n\t\treturn (\n\t\t\terror instanceof MongoServerError ||\n\t\t\terror instanceof MongoError ||\n\t\t\t(typeof error === 'object' &&\n\t\t\t\terror !== null &&\n\t\t\t\t'code' in error &&\n\t\t\t\t'name' in error &&\n\t\t\t\t((error as MongoServerError).name === 'MongoServerError' ||\n\t\t\t\t\t(error as MongoServerError).name === 'MongoError'))\n\t\t);\n\t}\n\n\t/**\n\t * Creates a TRPC error from a MongoDB error\n\t * @private\n\t * @param error - MongoDB error to transform\n\t * @returns Transformed TRPC error\n\t */\n\tprivate static createMongoTRPCError(error: MongoServerError): TRPCError {\n\t\tconst errorCode = typeof error.code === 'number' ? error.code : 0;\n\t\tconst errorInfo = this.MONGO_ERROR_CODES[errorCode] || {\n\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\tmessage: `Database error occurred. Code: ${errorCode}`,\n\t\t};\n\n\t\treturn new TRPCError({\n\t\t\tcode: errorInfo.code,\n\t\t\tmessage: errorInfo.message,\n\t\t\tcause: error,\n\t\t});\n\t}\n\n\t/**\n\t * Maps Node.js error codes to TRPC error codes\n\t * @private\n\t * @param error - Node.js error to map\n\t * @returns Appropriate TRPC error code\n\t */\n\tprivate static mapNodeErrorCode(error: Error): TRPCError['code'] {\n\t\tconst nodeErrorMap: Record<string, TRPCError['code']> = {\n\t\t\tENOENT: 'NOT_FOUND',\n\t\t\tEACCES: 'FORBIDDEN',\n\t\t\tECONNREFUSED: 'INTERNAL_SERVER_ERROR',\n\t\t\tECONNRESET: 'INTERNAL_SERVER_ERROR',\n\t\t\tETIMEDOUT: 'TIMEOUT',\n\t\t\tEPIPE: 'INTERNAL_SERVER_ERROR',\n\t\t\tENOTFOUND: 'NOT_FOUND',\n\t\t\tEINVAL: 'BAD_REQUEST',\n\t\t\tEMFILE: 'INTERNAL_SERVER_ERROR',\n\t\t\tEPERM: 'FORBIDDEN',\n\t\t};\n\n\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\treturn code ? nodeErrorMap[code] || 'INTERNAL_SERVER_ERROR' : 'INTERNAL_SERVER_ERROR';\n\t}\n\n\t/**\n\t * Wraps an async function with error handling\n\t * @param fn - Async function to wrap\n\t * @param context - Additional context information\n\t * @returns Promise resolving to the function's return type\n\t * @throws {TRPCError} If the function throws an error\n\t */\n\tpublic static async wrapAsync<T>(fn: () => Promise<T>, context: Record<string, unknown> = {}): Promise<T> {\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} catch (error) {\n\t\t\tthis.handleError(error, undefined, context);\n\t\t}\n\t}\n\n\t/**\n\t * Executes an async function with retry mechanism for transient errors\n\t * @param fn - Async function to execute\n\t * @param options - Retry configuration options\n\t * @returns Promise resolving to the function's return type\n\t * @throws {TRPCError} If all retry attempts fail\n\t */\n\tpublic static async withRetry<T>(\n\t\tfn: () => Promise<T>,\n\t\toptions: {\n\t\t\tmaxAttempts?: number;\n\t\t\tdelayMs?: number;\n\t\t\tbackoffFactor?: number;\n\t\t\tcontext?: Record<string, unknown>;\n\t\t} = {}\n\t): Promise<T> {\n\t\tconst { maxAttempts = 3, delayMs = 1000, backoffFactor = 2, context = {} } = options;\n\n\t\tlet lastError: unknown;\n\t\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await fn();\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error;\n\n\t\t\t\tconst isRetryable = this.isRetryableError(error);\n\t\t\t\tconst isLastAttempt = attempt === maxAttempts;\n\n\t\t\t\tif (!isRetryable || isLastAttempt) {\n\t\t\t\t\tthis.handleError(error, undefined, { ...context, attempt });\n\t\t\t\t}\n\n\t\t\t\tawait new Promise(resolve => setTimeout(resolve, delayMs * Math.pow(backoffFactor, attempt - 1)));\n\t\t\t}\n\t\t}\n\n\t\tthrow lastError;\n\t}\n\n\t/**\n\t * Determines if an error is retryable\n\t * @private\n\t * @param error - The error to check\n\t * @returns True if the error is retryable\n\t */\n\tprivate static isRetryableError(error: unknown): boolean {\n\t\tif (error instanceof MongoNetworkError) return true;\n\t\tif (error instanceof Error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\treturn code ? this.CONFIG.retryableErrors.has(code) : false;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Extracts metadata from an error for logging and analysis\n\t * @param error - The error to extract metadata from\n\t * @returns Object containing error type, original error, and additional details\n\t */\n\tpublic static extractErrorMetadata(error: unknown): {\n\t\ttype: string;\n\t\toriginalError: unknown;\n\t\tdetails?: Record<string, unknown>;\n\t} {\n\t\tif (error instanceof TRPCError) {\n\t\t\treturn {\n\t\t\t\ttype: 'TRPCError',\n\t\t\t\toriginalError: error.cause ?? error,\n\t\t\t\tdetails: {\n\t\t\t\t\tcode: error.code,\n\t\t\t\t\tmessage: error.message,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (error instanceof ZodError) {\n\t\t\treturn {\n\t\t\t\ttype: 'ZodError',\n\t\t\t\toriginalError: error,\n\t\t\t\tdetails: error.flatten(),\n\t\t\t};\n\t\t}\n\n\t\tif (error instanceof MongoNetworkError) {\n\t\t\treturn {\n\t\t\t\ttype: 'MongoNetworkError',\n\t\t\t\toriginalError: error,\n\t\t\t\tdetails: {\n\t\t\t\t\tmessage: error.message,\n\t\t\t\t\tisRetryable: true,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (this.isMongoError(error)) {\n\t\t\treturn {\n\t\t\t\ttype: 'MongoError',\n\t\t\t\toriginalError: error,\n\t\t\t\tdetails: {\n\t\t\t\t\tcode: (error as MongoServerError).code,\n\t\t\t\t\tcodeName: (error as MongoServerError).codeName,\n\t\t\t\t\tkeyPattern: (error as MongoServerError).keyPattern,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (error instanceof Error) {\n\t\t\treturn {\n\t\t\t\ttype: 'NodeError',\n\t\t\t\toriginalError: error,\n\t\t\t\tdetails: {\n\t\t\t\t\tname: error.name,\n\t\t\t\t\tcode: (error as NodeJS.ErrnoException).code,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn { type: 'UnknownError', originalError: error };\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"/","sources":["utilities/error-handler.ts"],"names":[],"mappings":";;;AAKA,yCAAyC;AACzC,qCAA0E;AAC1E,6BAA+B;AAM/B,MAAa,YAAY;IAKhB,MAAM,CAAU,MAAM,GAAG;QA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E,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IACvD,CAAC;;AAtUF,oCAuUC","sourcesContent":["/**\n * @fileoverview Error handling utility for TRPC and MongoDB operations.\n * Provides centralized error handling, logging, and retry mechanisms.\n */\n\nimport { TRPCError } from '@trpc/server';\nimport { MongoServerError, MongoError, MongoNetworkError } from 'mongodb';\nimport { ZodError } from 'zod';\n\n/**\n * A utility class for handling various types of errors in a TRPC-MongoDB application.\n * Provides error transformation, logging, and retry mechanisms.\n */\nexport class ErrorHandler {\n\t/**\n\t * Configuration options for error handling behavior\n\t * @private\n\t */\n\tprivate static readonly CONFIG = {\n\t\t/** Whether to log errors to console */\n\t\tshouldLogErrors: true,\n\t\t/** Maximum number of stack trace lines to include in logs */\n\t\tmaxStackTraceLines: 10,\n\t\t/** Set of error codes that are considered retryable */\n\t\tretryableErrors: new Set(['ECONNRESET', 'ECONNREFUSED', 'ETIMEDOUT', 'EPIPE']),\n\t};\n\n\t/**\n\t * Mapping of MongoDB error codes to TRPC error types and messages\n\t * @private\n\t */\n\tprivate static readonly MONGO_ERROR_CODES: Record<\n\t\tnumber,\n\t\t{\n\t\t\tcode: TRPCError['code'];\n\t\t\tmessage: string;\n\t\t}\n\t> = {\n\t\t11000: { code: 'CONFLICT', message: 'A record with this value already exists.' },\n\t\t11001: { code: 'CONFLICT', message: 'Duplicate key error on index update.' },\n\t\t121: { code: 'BAD_REQUEST', message: 'Document validation failed.' },\n\t\t7: { code: 'INTERNAL_SERVER_ERROR', message: 'Not primary - database is in recovery mode.' },\n\t\t89: { code: 'FORBIDDEN', message: 'Unauthorized operation attempted.' },\n\t\t91: { code: 'TIMEOUT', message: 'Operation timeout exceeded.' },\n\t\t189: { code: 'BAD_REQUEST', message: 'Invalid modification - document would exceed size limit.' },\n\t\t50: { code: 'INTERNAL_SERVER_ERROR', message: 'Database execution error.' },\n\t};\n\n\t/**\n\t * Logs error information with metadata and stack trace\n\t * @private\n\t * @param error - The error to log\n\t * @param context - Additional context information for the error\n\t */\n\tprivate static logError(error: unknown, context: Record<string, unknown> = {}): void {\n\t\tif (!this.CONFIG.shouldLogErrors) return;\n\n\t\tconst errorMeta = this.extractErrorMetadata(error);\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tconst logData = {\n\t\t\ttimestamp,\n\t\t\ttype: errorMeta.type,\n\t\t\tmessage: error instanceof Error ? error.message : 'Unknown error',\n\t\t\tstack:\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? error.stack?.split('\\n').slice(0, this.CONFIG.maxStackTraceLines).join('\\n')\n\t\t\t\t\t: undefined,\n\t\t\tcontext,\n\t\t\tmetadata: errorMeta,\n\t\t};\n\n\t\tconsole.error('[ErrorHandler]:', JSON.stringify(logData, null, 2));\n\t}\n\n\t/**\n\t * Main error handling method that transforms various error types into TRPC errors\n\t * @param error - The error to handle\n\t * @param customMessage - Optional custom error message\n\t * @param context - Additional context information\n\t * @throws {TRPCError} Transformed error with appropriate error code and message\n\t */\n\tpublic static handleError(\n\t\terror: unknown,\n\t\tcustomMessage = 'An unexpected error occurred',\n\t\tcontext: Record<string, unknown> = {}\n\t): never {\n\t\tthis.logError(error, context);\n\n\t\tif (error instanceof TRPCError) {\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (error instanceof ZodError) {\n\t\t\ttry {\n\t\t\t\tconsole.log('ZodError:', error.flatten());\n\t\t\t\tconst formatted = error.errors.map(e => ({\n\t\t\t\t\tfield: e.path.join('.'),\n\t\t\t\t\tmessage: e.message,\n\t\t\t\t}));\n\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'BAD_REQUEST',\n\t\t\t\t\tmessage: 'Validation error',\n\t\t\t\t\tcause: formatted,\n\t\t\t\t});\n\t\t\t} catch (err) {\n\t\t\t\t// Handle any issues with flattening or logging\n\t\t\t\tconsole.error('Error while processing ZodError:', err);\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\t\tmessage: 'Error processing validation error',\n\t\t\t\t\tcause: err,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (error instanceof MongoNetworkError) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\t\tmessage: 'Database connection error',\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\n\t\tif (this.isMongoError(error)) {\n\t\t\tthrow this.createMongoTRPCError(error);\n\t\t}\n\n\t\tif (error instanceof Error) {\n\t\t\tthrow new TRPCError({\n\t\t\t\tcode: this.mapNodeErrorCode(error),\n\t\t\t\tmessage: error.message || customMessage,\n\t\t\t\tcause: error,\n\t\t\t});\n\t\t}\n\n\t\tthrow new TRPCError({\n\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\tmessage: customMessage,\n\t\t\tcause: error,\n\t\t});\n\t}\n\n\t/**\n\t * Type guard to check if an error is a MongoDB error\n\t * @private\n\t * @param error - The error to check\n\t * @returns True if the error is a MongoDB error\n\t */\n\tprivate static isMongoError(error: unknown): error is MongoServerError {\n\t\treturn (\n\t\t\terror instanceof MongoServerError ||\n\t\t\terror instanceof MongoError ||\n\t\t\t(typeof error === 'object' &&\n\t\t\t\terror !== null &&\n\t\t\t\t'code' in error &&\n\t\t\t\t'name' in error &&\n\t\t\t\t((error as MongoServerError).name === 'MongoServerError' ||\n\t\t\t\t\t(error as MongoServerError).name === 'MongoError'))\n\t\t);\n\t}\n\n\t/**\n\t * Creates a TRPC error from a MongoDB error\n\t * @private\n\t * @param error - MongoDB error to transform\n\t * @returns Transformed TRPC error\n\t */\n\tprivate static createMongoTRPCError(error: MongoServerError): TRPCError {\n\t\tconst errorCode = typeof error.code === 'number' ? error.code : 0;\n\t\tconst errorInfo = this.MONGO_ERROR_CODES[errorCode] || {\n\t\t\tcode: 'INTERNAL_SERVER_ERROR',\n\t\t\tmessage: `Database error occurred. Code: ${errorCode}`,\n\t\t};\n\n\t\treturn new TRPCError({\n\t\t\tcode: errorInfo.code,\n\t\t\tmessage: errorInfo.message,\n\t\t\tcause: error,\n\t\t});\n\t}\n\n\t/**\n\t * Maps Node.js error codes to TRPC error codes\n\t * @private\n\t * @param error - Node.js error to map\n\t * @returns Appropriate TRPC error code\n\t */\n\tprivate static mapNodeErrorCode(error: Error): TRPCError['code'] {\n\t\tconst nodeErrorMap: Record<string, TRPCError['code']> = {\n\t\t\tENOENT: 'NOT_FOUND',\n\t\t\tEACCES: 'FORBIDDEN',\n\t\t\tECONNREFUSED: 'INTERNAL_SERVER_ERROR',\n\t\t\tECONNRESET: 'INTERNAL_SERVER_ERROR',\n\t\t\tETIMEDOUT: 'TIMEOUT',\n\t\t\tEPIPE: 'INTERNAL_SERVER_ERROR',\n\t\t\tENOTFOUND: 'NOT_FOUND',\n\t\t\tEINVAL: 'BAD_REQUEST',\n\t\t\tEMFILE: 'INTERNAL_SERVER_ERROR',\n\t\t\tEPERM: 'FORBIDDEN',\n\t\t};\n\n\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\treturn code ? nodeErrorMap[code] || 'INTERNAL_SERVER_ERROR' : 'INTERNAL_SERVER_ERROR';\n\t}\n\n\t/**\n\t * Wraps an async function with error handling\n\t * @param fn - Async function to wrap\n\t * @param context - Additional context information\n\t * @returns Promise resolving to the function's return type\n\t * @throws {TRPCError} If the function throws an error\n\t */\n\tpublic static async wrapAsync<T>(fn: () => Promise<T>, context: Record<string, unknown> = {}): Promise<T> {\n\t\ttry {\n\t\t\treturn await fn();\n\t\t} catch (error) {\n\t\t\tthis.handleError(error, undefined, context);\n\t\t}\n\t}\n\n\t/**\n\t * Executes an async function with retry mechanism for transient errors\n\t * @param fn - Async function to execute\n\t * @param options - Retry configuration options\n\t * @returns Promise resolving to the function's return type\n\t * @throws {TRPCError} If all retry attempts fail\n\t */\n\tpublic static async withRetry<T>(\n\t\tfn: () => Promise<T>,\n\t\toptions: {\n\t\t\tmaxAttempts?: number;\n\t\t\tdelayMs?: number;\n\t\t\tbackoffFactor?: number;\n\t\t\tcontext?: Record<string, unknown>;\n\t\t} = {}\n\t): Promise<T> {\n\t\tconst { maxAttempts = 3, delayMs = 1000, backoffFactor = 2, context = {} } = options;\n\n\t\tlet lastError: unknown;\n\t\tfor (let attempt = 1; attempt <= maxAttempts; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await fn();\n\t\t\t} catch (error) {\n\t\t\t\tlastError = error;\n\n\t\t\t\tconst isRetryable = this.isRetryableError(error);\n\t\t\t\tconst isLastAttempt = attempt === maxAttempts;\n\n\t\t\t\tif (!isRetryable || isLastAttempt) {\n\t\t\t\t\tthis.handleError(error, undefined, { ...context, attempt });\n\t\t\t\t}\n\n\t\t\t\tawait new Promise(resolve => setTimeout(resolve, delayMs * Math.pow(backoffFactor, attempt - 1)));\n\t\t\t}\n\t\t}\n\n\t\tthrow lastError;\n\t}\n\n\t/**\n\t * Determines if an error is retryable\n\t * @private\n\t * @param error - The error to check\n\t * @returns True if the error is retryable\n\t */\n\tprivate static isRetryableError(error: unknown): boolean {\n\t\tif (error instanceof MongoNetworkError) return true;\n\t\tif (error instanceof Error) {\n\t\t\tconst code = (error as NodeJS.ErrnoException).code;\n\t\t\treturn code ? this.CONFIG.retryableErrors.has(code) : false;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Extracts metadata from an error for logging and analysis\n\t * @param error - The error to extract metadata from\n\t * @returns Object containing error type, original error, and additional details\n\t */\n\tpublic static extractErrorMetadata(error: unknown): {\n\t\ttype: string;\n\t\toriginalError: unknown;\n\t\tdetails?: Record<string, unknown>;\n\t} {\n\t\tif (error instanceof TRPCError) {\n\t\t\treturn {\n\t\t\t\ttype: 'TRPCError',\n\t\t\t\toriginalError: error.cause ?? error,\n\t\t\t\tdetails: {\n\t\t\t\t\tcode: error.code,\n\t\t\t\t\tmessage: error.message,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (error instanceof ZodError) {\n\t\t\treturn {\n\t\t\t\ttype: 'ZodError',\n\t\t\t\toriginalError: error,\n\t\t\t\tdetails: error.flatten(),\n\t\t\t};\n\t\t}\n\n\t\tif (error instanceof MongoNetworkError) {\n\t\t\treturn {\n\t\t\t\ttype: 'MongoNetworkError',\n\t\t\t\toriginalError: error,\n\t\t\t\tdetails: {\n\t\t\t\t\tmessage: error.message,\n\t\t\t\t\tisRetryable: true,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (this.isMongoError(error)) {\n\t\t\treturn {\n\t\t\t\ttype: 'MongoError',\n\t\t\t\toriginalError: error,\n\t\t\t\tdetails: {\n\t\t\t\t\tcode: (error as MongoServerError).code,\n\t\t\t\t\tcodeName: (error as MongoServerError).codeName,\n\t\t\t\t\tkeyPattern: (error as MongoServerError).keyPattern,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tif (error instanceof Error) {\n\t\t\treturn {\n\t\t\t\ttype: 'NodeError',\n\t\t\t\toriginalError: error,\n\t\t\t\tdetails: {\n\t\t\t\t\tname: error.name,\n\t\t\t\t\tcode: (error as NodeJS.ErrnoException).code,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treturn { type: 'UnknownError', originalError: error };\n\t}\n}\n"]}
|
|
@@ -195,7 +195,7 @@ export declare const AddressSchema: z.ZodObject<{
|
|
|
195
195
|
city?: string | null | undefined;
|
|
196
196
|
zone?: string | import("mongoose").Types.ObjectId | undefined;
|
|
197
197
|
}>;
|
|
198
|
-
export declare const UserAddressSchema: z.ZodObject<
|
|
198
|
+
export declare const UserAddressSchema: z.ZodObject<{
|
|
199
199
|
address: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
200
200
|
description: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
201
201
|
city: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -214,13 +214,13 @@ export declare const UserAddressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
214
214
|
latitude: z.ZodNumber;
|
|
215
215
|
longitude: z.ZodNumber;
|
|
216
216
|
zone: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
|
|
217
|
-
}
|
|
217
|
+
} & {
|
|
218
218
|
addressLabel: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
219
219
|
apartment: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
220
220
|
buildingName: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
221
221
|
deliveryOption: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
222
222
|
instructions: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
223
|
-
}
|
|
223
|
+
}, "strip", z.ZodTypeAny, {
|
|
224
224
|
location: {
|
|
225
225
|
type: GeoLocationType;
|
|
226
226
|
coordinates: [number, number];
|
|
@@ -257,7 +257,7 @@ export declare const UserAddressSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
257
257
|
deliveryOption?: string | null | undefined;
|
|
258
258
|
instructions?: string | null | undefined;
|
|
259
259
|
}>;
|
|
260
|
-
export declare const CourierAddressSchema: z.ZodObject<
|
|
260
|
+
export declare const CourierAddressSchema: z.ZodObject<{
|
|
261
261
|
address: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
262
262
|
description: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
263
263
|
city: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -276,16 +276,16 @@ export declare const CourierAddressSchema: z.ZodObject<z.objectUtil.extendShape<
|
|
|
276
276
|
latitude: z.ZodNumber;
|
|
277
277
|
longitude: z.ZodNumber;
|
|
278
278
|
zone: z.ZodOptional<z.ZodUnion<[z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, import("mongoose").Types.ObjectId, string>, z.ZodType<import("mongoose").Types.ObjectId, z.ZodTypeDef, import("mongoose").Types.ObjectId>]>>;
|
|
279
|
-
}
|
|
279
|
+
} & {
|
|
280
280
|
addressLabel: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
281
281
|
apartment: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
282
282
|
buildingName: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
283
283
|
deliveryOption: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
284
284
|
instructions: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodString>> | z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
285
|
-
}
|
|
285
|
+
} & {
|
|
286
286
|
name: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
287
287
|
phoneNumber: z.ZodString | z.ZodOptional<z.ZodString> | z.ZodNullable<z.ZodString> | z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
288
|
-
}
|
|
288
|
+
}, "strip", z.ZodTypeAny, {
|
|
289
289
|
location: {
|
|
290
290
|
type: GeoLocationType;
|
|
291
291
|
coordinates: [number, number];
|
|
@@ -63,52 +63,36 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
63
63
|
private baseSchema;
|
|
64
64
|
constructor(baseFields: T, includeTimestamps?: boolean, includeTracking?: boolean);
|
|
65
65
|
private createBaseSchema;
|
|
66
|
-
getBaseSchema(): z.ZodObject<T,
|
|
66
|
+
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>;
|
|
67
67
|
getEntitySchema(): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
68
68
|
_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>]>;
|
|
69
69
|
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
70
70
|
_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>]>;
|
|
71
|
-
}>[k]>; } : never,
|
|
71
|
+
}>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
72
72
|
_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>]>;
|
|
73
|
-
}> extends infer
|
|
73
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
74
74
|
_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>]>;
|
|
75
|
-
}>[k]>; } : never
|
|
75
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
76
76
|
_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>]>;
|
|
77
77
|
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
78
78
|
_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>]>;
|
|
79
|
-
}>[k]>; } : never
|
|
80
|
-
_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>]>;
|
|
81
|
-
}> extends infer T_7 extends z.ZodRawShape ? { [k in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
82
|
-
_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>]>;
|
|
83
|
-
}>[k]>; } : never> extends infer T_5 ? { [k_2 in keyof T_5]: z.baseObjectInputType<z.objectUtil.extendShape<T, {
|
|
84
|
-
_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>]>;
|
|
85
|
-
}> extends infer T_6 extends z.ZodRawShape ? { [k in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
86
|
-
_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>]>;
|
|
87
|
-
}>[k]>; } : never>[k_2]; } : never>;
|
|
79
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
88
80
|
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>]>;
|
|
89
81
|
getUpdateSchema(excludeFields?: ExcludeFromUpdate): z.ZodObject<z.objectUtil.extendShape<T, {
|
|
90
82
|
_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>]>;
|
|
91
83
|
}> extends infer T_1 extends z.ZodRawShape ? { [k in keyof T_1]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
92
84
|
_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>]>;
|
|
93
|
-
}>[k]>; } : never,
|
|
85
|
+
}>[k]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
94
86
|
_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>]>;
|
|
95
|
-
}> extends infer
|
|
87
|
+
}> extends infer T_2 extends z.ZodRawShape ? { [k in keyof T_2]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
96
88
|
_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>]>;
|
|
97
|
-
}>[k]>; } : never
|
|
89
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
98
90
|
_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>]>;
|
|
99
91
|
}> extends infer T_3 extends z.ZodRawShape ? { [k in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
100
92
|
_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>]>;
|
|
101
|
-
}>[k]>; } : never
|
|
102
|
-
_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>]>;
|
|
103
|
-
}> extends infer T_7 extends z.ZodRawShape ? { [k in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
104
|
-
_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>]>;
|
|
105
|
-
}>[k]>; } : never> extends infer T_5 ? { [k_2 in keyof T_5]: z.baseObjectInputType<z.objectUtil.extendShape<T, {
|
|
106
|
-
_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>]>;
|
|
107
|
-
}> extends infer T_6 extends z.ZodRawShape ? { [k in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
108
|
-
_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>]>;
|
|
109
|
-
}>[k]>; } : never>[k_2]; } : never> | z.ZodObject<{
|
|
93
|
+
}>[k]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
110
94
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
111
|
-
}, "
|
|
95
|
+
}, "strict", z.ZodTypeAny, {
|
|
112
96
|
[x: string]: any;
|
|
113
97
|
}, {
|
|
114
98
|
[x: string]: any;
|
|
@@ -129,52 +113,36 @@ export declare class SchemaBuilder<T extends z.ZodRawShape> {
|
|
|
129
113
|
[x: string]: any;
|
|
130
114
|
}>;
|
|
131
115
|
getAllSchemas(excludeFromUpdate?: ExcludeFromUpdate): {
|
|
132
|
-
BaseSchema: z.ZodObject<T,
|
|
116
|
+
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>;
|
|
133
117
|
EntitySchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
134
118
|
_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>]>;
|
|
135
119
|
}> extends infer T_3 extends z.ZodRawShape ? { [k_2 in keyof T_3]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
136
120
|
_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>]>;
|
|
137
|
-
}>[k_2]>; } : never,
|
|
121
|
+
}>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
138
122
|
_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>]>;
|
|
139
|
-
}> extends infer
|
|
123
|
+
}> extends infer T_4 extends z.ZodRawShape ? { [k_2 in keyof T_4]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
140
124
|
_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>]>;
|
|
141
|
-
}>[k_2]>; } : never
|
|
125
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
142
126
|
_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>]>;
|
|
143
127
|
}> extends infer T_5 extends z.ZodRawShape ? { [k_2 in keyof T_5]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
144
128
|
_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>]>;
|
|
145
|
-
}>[k_2]>; } : never
|
|
146
|
-
_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>]>;
|
|
147
|
-
}> extends infer T_9 extends z.ZodRawShape ? { [k_2 in keyof T_9]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
148
|
-
_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>]>;
|
|
149
|
-
}>[k_2]>; } : never> extends infer T_7 ? { [k_4 in keyof T_7]: z.baseObjectInputType<z.objectUtil.extendShape<T, {
|
|
150
|
-
_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>]>;
|
|
151
|
-
}> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
152
|
-
_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>]>;
|
|
153
|
-
}>[k_2]>; } : never>[k_4]; } : never>;
|
|
129
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">>;
|
|
154
130
|
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>]>;
|
|
155
131
|
UpdateSchema: z.ZodObject<z.objectUtil.extendShape<T, {
|
|
156
132
|
_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>]>;
|
|
157
|
-
}> extends infer
|
|
158
|
-
_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>]>;
|
|
159
|
-
}>[k_2]>; } : never, z.UnknownKeysParam, z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<T, {
|
|
160
|
-
_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>]>;
|
|
161
|
-
}> extends infer T_13 extends z.ZodRawShape ? { [k_2 in keyof T_13]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
162
|
-
_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>]>;
|
|
163
|
-
}>[k_2]>; } : never>, any> extends infer T_11 ? { [k_3 in keyof T_11]: z.objectUtil.addQuestionMarks<z.baseObjectOutputType<z.objectUtil.extendShape<T, {
|
|
164
|
-
_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>]>;
|
|
165
|
-
}> extends infer T_12 extends z.ZodRawShape ? { [k_2 in keyof T_12]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
133
|
+
}> extends infer T_6 extends z.ZodRawShape ? { [k_2 in keyof T_6]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
166
134
|
_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>]>;
|
|
167
|
-
}>[k_2]>; } : never
|
|
135
|
+
}>[k_2]>; } : never, "passthrough", z.ZodTypeAny, z.objectOutputType<z.objectUtil.extendShape<T, {
|
|
168
136
|
_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>]>;
|
|
169
|
-
}> extends infer
|
|
137
|
+
}> extends infer T_7 extends z.ZodRawShape ? { [k_2 in keyof T_7]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
170
138
|
_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>]>;
|
|
171
|
-
}>[k_2]>; } : never
|
|
139
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">, z.objectInputType<z.objectUtil.extendShape<T, {
|
|
172
140
|
_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>]>;
|
|
173
|
-
}> extends infer
|
|
141
|
+
}> extends infer T_8 extends z.ZodRawShape ? { [k_2 in keyof T_8]: z.ZodOptional<z.objectUtil.extendShape<T, {
|
|
174
142
|
_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>]>;
|
|
175
|
-
}>[k_2]>; } : never
|
|
143
|
+
}>[k_2]>; } : never, z.ZodTypeAny, "passthrough">> | z.ZodObject<{
|
|
176
144
|
[x: string]: z.ZodOptional<z.ZodTypeAny>;
|
|
177
|
-
}, "
|
|
145
|
+
}, "strict", z.ZodTypeAny, {
|
|
178
146
|
[x: string]: any;
|
|
179
147
|
}, {
|
|
180
148
|
[x: string]: any;
|
|
@@ -63,7 +63,7 @@ class ZodValidation {
|
|
|
63
63
|
schema = schema.min(options.minLength, options.minMessage || `${field} must be at least ${options.minLength} characters`);
|
|
64
64
|
}
|
|
65
65
|
if (options?.maxLength) {
|
|
66
|
-
schema = schema.max(options.maxLength, options.maxMessage || `${field}
|
|
66
|
+
schema = schema.max(options.maxLength, options.maxMessage || `${field} shouldn’t exceed ${options.maxLength} characters`);
|
|
67
67
|
}
|
|
68
68
|
if (options?.regex) {
|
|
69
69
|
schema = schema.regex(options.regex.pattern, options.regex.message);
|
|
@@ -178,17 +178,18 @@ class SchemaBuilder {
|
|
|
178
178
|
return zod_1.z.object({
|
|
179
179
|
...baseFields,
|
|
180
180
|
...additionalFields,
|
|
181
|
-
})
|
|
181
|
+
});
|
|
182
182
|
}
|
|
183
183
|
getBaseSchema() {
|
|
184
|
-
return this.baseSchema;
|
|
184
|
+
return this.baseSchema.strict();
|
|
185
185
|
}
|
|
186
186
|
getEntitySchema() {
|
|
187
187
|
return this.baseSchema
|
|
188
188
|
.extend({
|
|
189
189
|
_id: ZodValidation.objectId(),
|
|
190
190
|
})
|
|
191
|
-
.partial()
|
|
191
|
+
.partial()
|
|
192
|
+
.passthrough();
|
|
192
193
|
}
|
|
193
194
|
getIdSchema() {
|
|
194
195
|
return ZodValidation.objectId();
|
|
@@ -205,7 +206,7 @@ class SchemaBuilder {
|
|
|
205
206
|
filteredShape[key] = shape[key];
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
|
-
return zod_1.z.object(filteredShape).partial();
|
|
209
|
+
return zod_1.z.object(filteredShape).partial().strict();
|
|
209
210
|
}
|
|
210
211
|
getDeleteSchema() {
|
|
211
212
|
return zod_1.z.object({
|