@lyxa.ai/core 1.4.49 → 1.4.51-beta.0
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/embedded/service-booking-refund-information.model.d.ts +16 -0
- package/dist/libraries/mongo/models/embedded/service-booking-refund-information.model.js +70 -0
- package/dist/libraries/mongo/models/embedded/service-booking-refund-information.model.js.map +1 -0
- package/dist/libraries/mongo/models/embedded/service-booking-replacement-information.model.d.ts +19 -0
- package/dist/libraries/mongo/models/embedded/service-booking-replacement-information.model.js +76 -0
- package/dist/libraries/mongo/models/embedded/service-booking-replacement-information.model.js.map +1 -0
- package/dist/libraries/mongo/models/service-booking.model.d.ts +11 -2
- package/dist/libraries/mongo/models/service-booking.model.js +47 -6
- package/dist/libraries/mongo/models/service-booking.model.js.map +1 -1
- package/dist/libraries/mongo/models/service-flag.model.d.ts +13 -0
- package/dist/libraries/mongo/models/service-flag.model.js +54 -0
- package/dist/libraries/mongo/models/service-flag.model.js.map +1 -0
- package/dist/libraries/mongo/plugins/soft-delete-plugin.js +8 -2
- package/dist/libraries/mongo/plugins/soft-delete-plugin.js.map +1 -1
- package/dist/types/README.md +1 -1
- package/dist/types/package.json +1 -1
- package/dist/types/utilities/enum.d.ts +8 -4
- package/dist/types/utilities/enum.js +12 -7
- package/dist/types/utilities/enum.js.map +1 -1
- package/dist/utilities/enum.d.ts +8 -4
- package/dist/utilities/enum.js +12 -7
- package/dist/utilities/enum.js.map +1 -1
- package/package.json +1 -1
- package/dist/libraries/mongo/models/embedded/service-booking-flag.model.d.ts +0 -8
- package/dist/libraries/mongo/models/embedded/service-booking-flag.model.js +0 -43
- package/dist/libraries/mongo/models/embedded/service-booking-flag.model.js.map +0 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ServiceFlagReasonType } from '../../../../utilities/enum';
|
|
2
|
+
declare class SelectedLineItemsInfo {
|
|
3
|
+
lineItemId: string;
|
|
4
|
+
quantity?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class ServiceBookingRefundInformation {
|
|
7
|
+
selectedLineItems?: SelectedLineItemsInfo[];
|
|
8
|
+
refundedAmountByCompany?: number;
|
|
9
|
+
secondaryRefundedAmountByCompany?: number;
|
|
10
|
+
refundedAmountByVendor?: number;
|
|
11
|
+
secondaryRefundedAmountByVendor?: number;
|
|
12
|
+
totalRefund?: number;
|
|
13
|
+
secondaryTotalRefund?: number;
|
|
14
|
+
reasonType?: ServiceFlagReasonType;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
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.ServiceBookingRefundInformation = void 0;
|
|
13
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
+
const enum_1 = require("../../../../utilities/enum");
|
|
15
|
+
class SelectedLineItemsInfo {
|
|
16
|
+
lineItemId;
|
|
17
|
+
quantity;
|
|
18
|
+
}
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], SelectedLineItemsInfo.prototype, "lineItemId", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, typegoose_1.prop)({ type: Number, default: 1 }),
|
|
25
|
+
__metadata("design:type", Number)
|
|
26
|
+
], SelectedLineItemsInfo.prototype, "quantity", void 0);
|
|
27
|
+
class ServiceBookingRefundInformation {
|
|
28
|
+
selectedLineItems;
|
|
29
|
+
refundedAmountByCompany;
|
|
30
|
+
secondaryRefundedAmountByCompany;
|
|
31
|
+
refundedAmountByVendor;
|
|
32
|
+
secondaryRefundedAmountByVendor;
|
|
33
|
+
totalRefund;
|
|
34
|
+
secondaryTotalRefund;
|
|
35
|
+
reasonType;
|
|
36
|
+
}
|
|
37
|
+
exports.ServiceBookingRefundInformation = ServiceBookingRefundInformation;
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typegoose_1.prop)({ type: () => [SelectedLineItemsInfo], default: [], _id: false }),
|
|
40
|
+
__metadata("design:type", Array)
|
|
41
|
+
], ServiceBookingRefundInformation.prototype, "selectedLineItems", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
44
|
+
__metadata("design:type", Number)
|
|
45
|
+
], ServiceBookingRefundInformation.prototype, "refundedAmountByCompany", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
48
|
+
__metadata("design:type", Number)
|
|
49
|
+
], ServiceBookingRefundInformation.prototype, "secondaryRefundedAmountByCompany", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
52
|
+
__metadata("design:type", Number)
|
|
53
|
+
], ServiceBookingRefundInformation.prototype, "refundedAmountByVendor", void 0);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
56
|
+
__metadata("design:type", Number)
|
|
57
|
+
], ServiceBookingRefundInformation.prototype, "secondaryRefundedAmountByVendor", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
60
|
+
__metadata("design:type", Number)
|
|
61
|
+
], ServiceBookingRefundInformation.prototype, "totalRefund", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
64
|
+
__metadata("design:type", Number)
|
|
65
|
+
], ServiceBookingRefundInformation.prototype, "secondaryTotalRefund", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, typegoose_1.prop)({ type: String, enum: enum_1.ServiceFlagReasonType, default: enum_1.ServiceFlagReasonType.OTHER }),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], ServiceBookingRefundInformation.prototype, "reasonType", void 0);
|
|
70
|
+
//# sourceMappingURL=service-booking-refund-information.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-booking-refund-information.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/service-booking-refund-information.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA4C;AAC5C,qDAAmE;AAEnE,MAAM,qBAAqB;IAEnB,UAAU,CAAU;IAGpB,QAAQ,CAAU;CACzB;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDACZ;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACV;AAG1B,MAAa,+BAA+B;IAEpC,iBAAiB,CAA2B;IAG5C,uBAAuB,CAAU;IAGjC,gCAAgC,CAAU;IAG1C,sBAAsB,CAAU;IAGhC,+BAA+B,CAAU;IAGzC,WAAW,CAAU;IAGrB,oBAAoB,CAAU;IAG9B,UAAU,CAAyB;CAC1C;AAxBD,0EAwBC;AAtBO;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;;0EACpB;AAG5C;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;gFACK;AAGjC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;yFACc;AAG1C;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+EACI;AAGhC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;wFACa;AAGzC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;oEACP;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;6EACE;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAAqB,EAAE,OAAO,EAAE,4BAAqB,CAAC,KAAK,EAAE,CAAC;;mEAChD","sourcesContent":["import { prop } from '@typegoose/typegoose';\nimport { ServiceFlagReasonType } from '../../../../utilities/enum';\n\nclass SelectedLineItemsInfo {\n\t@prop({ required: true, type: String })\n\tpublic lineItemId!: string;\n\n\t@prop({ type: Number, default: 1 })\n\tpublic quantity?: number;\n}\n\nexport class ServiceBookingRefundInformation {\n\t@prop({ type: () => [SelectedLineItemsInfo], default: [], _id: false })\n\tpublic selectedLineItems?: SelectedLineItemsInfo[];\n\n\t@prop({ type: Number, default: 0 })\n\tpublic refundedAmountByCompany?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryRefundedAmountByCompany?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic refundedAmountByVendor?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryRefundedAmountByVendor?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic totalRefund?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryTotalRefund?: number;\n\n\t@prop({ type: String, enum: ServiceFlagReasonType, default: ServiceFlagReasonType.OTHER })\n\tpublic reasonType?: ServiceFlagReasonType;\n}\n"]}
|
package/dist/libraries/mongo/models/embedded/service-booking-replacement-information.model.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Ref } from '@typegoose/typegoose';
|
|
2
|
+
import { ServiceFlagReasonType } from '../../../../utilities/enum';
|
|
3
|
+
import { ServiceBooking } from '../service-booking.model';
|
|
4
|
+
declare class SelectedLineItemsInfo {
|
|
5
|
+
lineItemId: string;
|
|
6
|
+
quantity?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class ServiceBookingReplacementInformation {
|
|
9
|
+
originalBooking: Ref<ServiceBooking>;
|
|
10
|
+
selectedLineItems?: SelectedLineItemsInfo[];
|
|
11
|
+
replacementByCompany?: number;
|
|
12
|
+
secondaryReplacementByCompany?: number;
|
|
13
|
+
replacementByVendor?: number;
|
|
14
|
+
secondaryReplacementByVendor?: number;
|
|
15
|
+
totalReplacement?: number;
|
|
16
|
+
secondaryTotalReplacement?: number;
|
|
17
|
+
reasonType?: ServiceFlagReasonType;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
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.ServiceBookingReplacementInformation = void 0;
|
|
13
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
+
const enum_1 = require("../../../../utilities/enum");
|
|
15
|
+
const service_booking_model_1 = require("../service-booking.model");
|
|
16
|
+
class SelectedLineItemsInfo {
|
|
17
|
+
lineItemId;
|
|
18
|
+
quantity;
|
|
19
|
+
}
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], SelectedLineItemsInfo.prototype, "lineItemId", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typegoose_1.prop)({ type: Number, default: 1 }),
|
|
26
|
+
__metadata("design:type", Number)
|
|
27
|
+
], SelectedLineItemsInfo.prototype, "quantity", void 0);
|
|
28
|
+
class ServiceBookingReplacementInformation {
|
|
29
|
+
originalBooking;
|
|
30
|
+
selectedLineItems;
|
|
31
|
+
replacementByCompany;
|
|
32
|
+
secondaryReplacementByCompany;
|
|
33
|
+
replacementByVendor;
|
|
34
|
+
secondaryReplacementByVendor;
|
|
35
|
+
totalReplacement;
|
|
36
|
+
secondaryTotalReplacement;
|
|
37
|
+
reasonType;
|
|
38
|
+
}
|
|
39
|
+
exports.ServiceBookingReplacementInformation = ServiceBookingReplacementInformation;
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, typegoose_1.prop)({ required: true, ref: () => service_booking_model_1.ServiceBooking }),
|
|
42
|
+
__metadata("design:type", Object)
|
|
43
|
+
], ServiceBookingReplacementInformation.prototype, "originalBooking", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, typegoose_1.prop)({ type: () => [SelectedLineItemsInfo], default: [], _id: false }),
|
|
46
|
+
__metadata("design:type", Array)
|
|
47
|
+
], ServiceBookingReplacementInformation.prototype, "selectedLineItems", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
50
|
+
__metadata("design:type", Number)
|
|
51
|
+
], ServiceBookingReplacementInformation.prototype, "replacementByCompany", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
54
|
+
__metadata("design:type", Number)
|
|
55
|
+
], ServiceBookingReplacementInformation.prototype, "secondaryReplacementByCompany", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
58
|
+
__metadata("design:type", Number)
|
|
59
|
+
], ServiceBookingReplacementInformation.prototype, "replacementByVendor", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
62
|
+
__metadata("design:type", Number)
|
|
63
|
+
], ServiceBookingReplacementInformation.prototype, "secondaryReplacementByVendor", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
66
|
+
__metadata("design:type", Number)
|
|
67
|
+
], ServiceBookingReplacementInformation.prototype, "totalReplacement", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
(0, typegoose_1.prop)({ type: Number, default: 0 }),
|
|
70
|
+
__metadata("design:type", Number)
|
|
71
|
+
], ServiceBookingReplacementInformation.prototype, "secondaryTotalReplacement", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, typegoose_1.prop)({ type: String, enum: enum_1.ServiceFlagReasonType, default: enum_1.ServiceFlagReasonType.OTHER }),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], ServiceBookingReplacementInformation.prototype, "reasonType", void 0);
|
|
76
|
+
//# sourceMappingURL=service-booking-replacement-information.model.js.map
|
package/dist/libraries/mongo/models/embedded/service-booking-replacement-information.model.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-booking-replacement-information.model.js","sourceRoot":"/","sources":["libraries/mongo/models/embedded/service-booking-replacement-information.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAiD;AACjD,qDAAmE;AACnE,oEAA0D;AAE1D,MAAM,qBAAqB;IAEnB,UAAU,CAAU;IAGpB,QAAQ,CAAU;CACzB;AAJO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;yDACZ;AAGpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uDACV;AAG1B,MAAa,oCAAoC;IAEzC,eAAe,CAAuB;IAGtC,iBAAiB,CAA2B;IAG5C,oBAAoB,CAAU;IAG9B,6BAA6B,CAAU;IAGvC,mBAAmB,CAAU;IAG7B,4BAA4B,CAAU;IAGtC,gBAAgB,CAAU;IAG1B,yBAAyB,CAAU;IAGnC,UAAU,CAAyB;CAC1C;AA3BD,oFA2BC;AAzBO;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,sCAAc,EAAE,CAAC;;6EACP;AAGtC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,qBAAqB,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;;+EACpB;AAG5C;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;kFACE;AAG9B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;2FACW;AAGvC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;iFACC;AAG7B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;0FACU;AAGtC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;8EACF;AAG1B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;uFACO;AAGnC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAAqB,EAAE,OAAO,EAAE,4BAAqB,CAAC,KAAK,EAAE,CAAC;;wEAChD","sourcesContent":["import { prop, Ref } from '@typegoose/typegoose';\nimport { ServiceFlagReasonType } from '../../../../utilities/enum';\nimport { ServiceBooking } from '../service-booking.model';\n\nclass SelectedLineItemsInfo {\n\t@prop({ required: true, type: String })\n\tpublic lineItemId!: string;\n\n\t@prop({ type: Number, default: 1 })\n\tpublic quantity?: number;\n}\n\nexport class ServiceBookingReplacementInformation {\n\t@prop({ required: true, ref: () => ServiceBooking })\n\tpublic originalBooking!: Ref<ServiceBooking>;\n\n\t@prop({ type: () => [SelectedLineItemsInfo], default: [], _id: false })\n\tpublic selectedLineItems?: SelectedLineItemsInfo[];\n\n\t@prop({ type: Number, default: 0 })\n\tpublic replacementByCompany?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryReplacementByCompany?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic replacementByVendor?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryReplacementByVendor?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic totalReplacement?: number;\n\n\t@prop({ type: Number, default: 0 })\n\tpublic secondaryTotalReplacement?: number;\n\n\t@prop({ type: String, enum: ServiceFlagReasonType, default: ServiceFlagReasonType.OTHER })\n\tpublic reasonType?: ServiceFlagReasonType;\n}\n"]}
|
|
@@ -3,7 +3,6 @@ import { User } from './user.model';
|
|
|
3
3
|
import { Vendor } from './vendor.model';
|
|
4
4
|
import { ServiceBookingStatus, ServiceType, SubServiceType } from '../../../utilities/enum';
|
|
5
5
|
import { Professional } from './professional.model';
|
|
6
|
-
import { ServiceBookingFlag } from './embedded/service-booking-flag.model';
|
|
7
6
|
import { ServiceCart } from './service-cart.model';
|
|
8
7
|
import { ServiceBookingFinance } from './embedded/service-booking-finance.model';
|
|
9
8
|
import { ServiceBookingCancelllationDetails, ServiceBookingEndorseLoss } from './embedded/service-booking-cancellation-details.model';
|
|
@@ -12,6 +11,9 @@ import { Review, VendorParent } from '.';
|
|
|
12
11
|
import { RegularOrderAddress } from './shared/address.model';
|
|
13
12
|
import { OrderSlotRange } from './shared/duration.model';
|
|
14
13
|
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
14
|
+
import { ServiceBookingRefundInformation } from './embedded/service-booking-refund-information.model';
|
|
15
|
+
import { ServiceBookingReplacementInformation } from './embedded/service-booking-replacement-information.model';
|
|
16
|
+
import { ServiceFlag } from './service-flag.model';
|
|
15
17
|
export declare class ServiceBooking extends TimeStamps {
|
|
16
18
|
orderId?: string;
|
|
17
19
|
user: Ref<User>;
|
|
@@ -25,7 +27,6 @@ export declare class ServiceBooking extends TimeStamps {
|
|
|
25
27
|
status: ServiceBookingStatus;
|
|
26
28
|
professionals?: Ref<Professional>[];
|
|
27
29
|
responsibleProfessional?: Ref<Professional>;
|
|
28
|
-
flag?: ServiceBookingFlag;
|
|
29
30
|
processedAt?: Date;
|
|
30
31
|
placedAt?: Date;
|
|
31
32
|
startedAt?: Date;
|
|
@@ -43,9 +44,17 @@ export declare class ServiceBooking extends TimeStamps {
|
|
|
43
44
|
isEndorseLossApplied?: boolean;
|
|
44
45
|
endorseLossInformation?: ServiceBookingEndorseLoss;
|
|
45
46
|
isAdjusted?: boolean;
|
|
47
|
+
isFlagged?: boolean;
|
|
48
|
+
flaggedAt?: Date;
|
|
49
|
+
isRefunded?: boolean;
|
|
50
|
+
refundInformation?: ServiceBookingRefundInformation;
|
|
51
|
+
isReplacement?: boolean;
|
|
52
|
+
replacementInformation?: ServiceBookingReplacementInformation;
|
|
53
|
+
replacementBooking?: Ref<ServiceBooking>;
|
|
46
54
|
statusTimeline?: ServiceBookingStatusTimeline[];
|
|
47
55
|
bufferTime?: number;
|
|
48
56
|
isReviewed?: boolean;
|
|
49
57
|
isReviewNotificationSent?: boolean;
|
|
58
|
+
flags?: Ref<ServiceFlag>[];
|
|
50
59
|
reviews?: Ref<Review>[];
|
|
51
60
|
}
|
|
@@ -15,7 +15,6 @@ const user_model_1 = require("./user.model");
|
|
|
15
15
|
const vendor_model_1 = require("./vendor.model");
|
|
16
16
|
const enum_1 = require("../../../utilities/enum");
|
|
17
17
|
const professional_model_1 = require("./professional.model");
|
|
18
|
-
const service_booking_flag_model_1 = require("./embedded/service-booking-flag.model");
|
|
19
18
|
const service_cart_model_1 = require("./service-cart.model");
|
|
20
19
|
const service_booking_finance_model_1 = require("./embedded/service-booking-finance.model");
|
|
21
20
|
const service_booking_cancellation_details_model_1 = require("./embedded/service-booking-cancellation-details.model");
|
|
@@ -25,6 +24,9 @@ const _1 = require(".");
|
|
|
25
24
|
const address_model_1 = require("./shared/address.model");
|
|
26
25
|
const duration_model_1 = require("./shared/duration.model");
|
|
27
26
|
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
27
|
+
const service_booking_refund_information_model_1 = require("./embedded/service-booking-refund-information.model");
|
|
28
|
+
const service_booking_replacement_information_model_1 = require("./embedded/service-booking-replacement-information.model");
|
|
29
|
+
const service_flag_model_1 = require("./service-flag.model");
|
|
28
30
|
let ServiceBooking = class ServiceBooking extends defaultClasses_1.TimeStamps {
|
|
29
31
|
orderId;
|
|
30
32
|
user;
|
|
@@ -38,7 +40,6 @@ let ServiceBooking = class ServiceBooking extends defaultClasses_1.TimeStamps {
|
|
|
38
40
|
status;
|
|
39
41
|
professionals;
|
|
40
42
|
responsibleProfessional;
|
|
41
|
-
flag;
|
|
42
43
|
processedAt;
|
|
43
44
|
placedAt;
|
|
44
45
|
startedAt;
|
|
@@ -56,10 +57,18 @@ let ServiceBooking = class ServiceBooking extends defaultClasses_1.TimeStamps {
|
|
|
56
57
|
isEndorseLossApplied;
|
|
57
58
|
endorseLossInformation;
|
|
58
59
|
isAdjusted;
|
|
60
|
+
isFlagged;
|
|
61
|
+
flaggedAt;
|
|
62
|
+
isRefunded;
|
|
63
|
+
refundInformation;
|
|
64
|
+
isReplacement;
|
|
65
|
+
replacementInformation;
|
|
66
|
+
replacementBooking;
|
|
59
67
|
statusTimeline;
|
|
60
68
|
bufferTime;
|
|
61
69
|
isReviewed;
|
|
62
70
|
isReviewNotificationSent;
|
|
71
|
+
flags;
|
|
63
72
|
reviews;
|
|
64
73
|
};
|
|
65
74
|
exports.ServiceBooking = ServiceBooking;
|
|
@@ -111,10 +120,6 @@ __decorate([
|
|
|
111
120
|
(0, typegoose_1.prop)({ ref: () => professional_model_1.Professional }),
|
|
112
121
|
__metadata("design:type", Object)
|
|
113
122
|
], ServiceBooking.prototype, "responsibleProfessional", void 0);
|
|
114
|
-
__decorate([
|
|
115
|
-
(0, typegoose_1.prop)({ type: () => service_booking_flag_model_1.ServiceBookingFlag, _id: false }),
|
|
116
|
-
__metadata("design:type", service_booking_flag_model_1.ServiceBookingFlag)
|
|
117
|
-
], ServiceBooking.prototype, "flag", void 0);
|
|
118
123
|
__decorate([
|
|
119
124
|
(0, typegoose_1.prop)({ type: Date, default: new Date() }),
|
|
120
125
|
__metadata("design:type", Date)
|
|
@@ -183,6 +188,34 @@ __decorate([
|
|
|
183
188
|
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
184
189
|
__metadata("design:type", Boolean)
|
|
185
190
|
], ServiceBooking.prototype, "isAdjusted", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
193
|
+
__metadata("design:type", Boolean)
|
|
194
|
+
], ServiceBooking.prototype, "isFlagged", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
(0, typegoose_1.prop)({ type: Date }),
|
|
197
|
+
__metadata("design:type", Date)
|
|
198
|
+
], ServiceBooking.prototype, "flaggedAt", void 0);
|
|
199
|
+
__decorate([
|
|
200
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
201
|
+
__metadata("design:type", Boolean)
|
|
202
|
+
], ServiceBooking.prototype, "isRefunded", void 0);
|
|
203
|
+
__decorate([
|
|
204
|
+
(0, typegoose_1.prop)({ type: service_booking_refund_information_model_1.ServiceBookingRefundInformation, _id: false }),
|
|
205
|
+
__metadata("design:type", service_booking_refund_information_model_1.ServiceBookingRefundInformation)
|
|
206
|
+
], ServiceBooking.prototype, "refundInformation", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
209
|
+
__metadata("design:type", Boolean)
|
|
210
|
+
], ServiceBooking.prototype, "isReplacement", void 0);
|
|
211
|
+
__decorate([
|
|
212
|
+
(0, typegoose_1.prop)({ type: () => service_booking_replacement_information_model_1.ServiceBookingReplacementInformation, _id: false }),
|
|
213
|
+
__metadata("design:type", service_booking_replacement_information_model_1.ServiceBookingReplacementInformation)
|
|
214
|
+
], ServiceBooking.prototype, "replacementInformation", void 0);
|
|
215
|
+
__decorate([
|
|
216
|
+
(0, typegoose_1.prop)({ ref: () => ServiceBooking }),
|
|
217
|
+
__metadata("design:type", Object)
|
|
218
|
+
], ServiceBooking.prototype, "replacementBooking", void 0);
|
|
186
219
|
__decorate([
|
|
187
220
|
(0, typegoose_1.prop)({ type: () => [status_timeline_model_1.ServiceBookingStatusTimeline], default: [] }),
|
|
188
221
|
__metadata("design:type", Array)
|
|
@@ -199,6 +232,14 @@ __decorate([
|
|
|
199
232
|
(0, typegoose_1.prop)({ type: Boolean, default: false }),
|
|
200
233
|
__metadata("design:type", Boolean)
|
|
201
234
|
], ServiceBooking.prototype, "isReviewNotificationSent", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
(0, typegoose_1.prop)({
|
|
237
|
+
ref: () => service_flag_model_1.ServiceFlag,
|
|
238
|
+
foreignField: 'serviceBooking',
|
|
239
|
+
localField: '_id',
|
|
240
|
+
}),
|
|
241
|
+
__metadata("design:type", Array)
|
|
242
|
+
], ServiceBooking.prototype, "flags", void 0);
|
|
202
243
|
__decorate([
|
|
203
244
|
(0, typegoose_1.prop)({
|
|
204
245
|
ref: () => _1.Review,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-booking.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-booking.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA8E;AAC9E,6CAAoC;AACpC,iDAAwC;AACxC,kDAAyG;AACzG,6DAAoD;AACpD,sFAA2E;AAC3E,6DAAmD;AACnD,4FAAiF;AACjF,sHAG+D;AAC/D,4EAAgF;AAChF,kEAA6D;AAC7D,wBAAuD;AACvD,0DAA6D;AAC7D,4DAAyD;AACzD,4EAAqE;AAW9D,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,2BAAU;IAEtC,OAAO,CAAU;IAGjB,IAAI,CAAa;IAGjB,MAAM,CAAe;IAGrB,MAAM,CAAqB;IAG3B,WAAW,CAAe;IAG1B,cAAc,CAAkB;IAGhC,IAAI,CAAoB;IAGxB,WAAW,CAAuB;IAGlC,SAAS,CAAkB;IAG3B,MAAM,CAAwB;IAG9B,aAAa,CAAuB;IAGpC,uBAAuB,CAAqB;IAG5C,IAAI,CAAsB;IAG1B,WAAW,CAAQ;IAGnB,QAAQ,CAAQ;IAGhB,SAAS,CAA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,EAAE,CAAC;;kDACZ;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,oDAA4B,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;sDACX;AAGhD;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;kDACI;AAIpB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;kDACZ;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;gEACE;AAOnC;IALN,IAAA,gBAAI,EAAC;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,SAAM;QACjB,YAAY,EAAE,gBAAgB;QAC9B,UAAU,EAAE,KAAK;KACjB,CAAC;;+CAC6B;yBA7GnB,cAAc;IAT1B,IAAA,wBAAY,EAAC;QACb,aAAa,EAAE,EAAE,UAAU,EAAE,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAE;QAClE,OAAO,EAAE,EAAE,UAAU,EAAE,oBAAQ,CAAC,KAAK,EAAE;KACvC,CAAC;IACD,IAAA,eAAG,EAAiB,MAAM,EAAE,KAAK;QACjC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,GAAG,MAAM,IAAA,yBAAU,EAAC,eAAY,EAAE,kBAAW,CAAC,OAAO,CAAC,CAAC;QACpE,CAAC;IACF,CAAC,CAAC;GACW,cAAc,CA8G1B","sourcesContent":["import { modelOptions, pre, prop, Ref, Severity } from '@typegoose/typegoose';\nimport { User } from './user.model';\nimport { Vendor } from './vendor.model';\nimport { ServiceBookingStatus, CounterType, ServiceType, SubServiceType } from '../../../utilities/enum';\nimport { Professional } from './professional.model';\nimport { ServiceBookingFlag } from './embedded/service-booking-flag.model';\nimport { ServiceCart } from './service-cart.model';\nimport { ServiceBookingFinance } from './embedded/service-booking-finance.model';\nimport {\n\tServiceBookingCancelllationDetails,\n\tServiceBookingEndorseLoss,\n} from './embedded/service-booking-cancellation-details.model';\nimport { ServiceBookingStatusTimeline } from './embedded/status-timeline.model';\nimport { generateId } from '../../../utilities/id-generator';\nimport { CounterModel, Review, VendorParent } from '.';\nimport { RegularOrderAddress } from './shared/address.model';\nimport { OrderSlotRange } from './shared/duration.model';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\n\n@modelOptions({\n\tschemaOptions: { collection: 'serviceBookings', timestamps: true },\n\toptions: { allowMixed: Severity.ALLOW },\n})\n@pre<ServiceBooking>('save', async function () {\n\tif (this.isNew) {\n\t\tthis.orderId = await generateId(CounterModel, CounterType.BOOKING);\n\t}\n})\nexport class ServiceBooking extends TimeStamps {\n\t@prop({ type: String, unique: true })\n\tpublic orderId?: string;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ required: true, ref: () => Vendor })\n\tpublic vendor!: Ref<Vendor>;\n\n\t@prop({ required: true, ref: () => VendorParent })\n\tpublic parent!: Ref<VendorParent>;\n\n\t@prop({ required: true, type: String, enum: ServiceType })\n\tpublic serviceType!: ServiceType;\n\n\t@prop({ type: String, enum: SubServiceType })\n\tpublic subServiceType?: SubServiceType;\n\n\t@prop({ required: true, ref: () => ServiceCart })\n\tpublic cart!: Ref<ServiceCart>;\n\n\t@prop({ required: true, type: () => RegularOrderAddress })\n\tpublic userAddress!: RegularOrderAddress;\n\n\t@prop({ required: true, type: OrderSlotRange, _id: false })\n\tpublic slotRange!: OrderSlotRange;\n\n\t@prop({ type: String, enum: ServiceBookingStatus, default: ServiceBookingStatus.PENDING })\n\tpublic status!: ServiceBookingStatus;\n\n\t@prop({ ref: () => Professional })\n\tpublic professionals?: Ref<Professional>[];\n\n\t@prop({ ref: () => Professional })\n\tpublic responsibleProfessional?: Ref<Professional>;\n\n\t@prop({ type: () => ServiceBookingFlag, _id: false })\n\tpublic flag?: ServiceBookingFlag;\n\n\t@prop({ type: Date, default: new Date() })\n\tpublic processedAt?: Date;\n\n\t@prop({ type: Date })\n\tpublic placedAt?: Date;\n\n\t@prop({ type: Date })\n\tpublic startedAt?: Date;\n\n\t@prop({ type: Date })\n\tpublic estimatedCompletionAt?: Date;\n\n\t@prop({ type: Number })\n\tpublic estimatedCompletionInMinutes?: number;\n\n\t@prop({ type: Date })\n\tpublic completedAt?: Date;\n\n\t@prop({ type: Number })\n\tpublic actualCompletionInMinutes?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isUrgentOrder?: boolean;\n\n\t@prop({ type: Date })\n\tpublic urgentAt?: Date;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isOverdue?: boolean;\n\n\t@prop({ type: Date })\n\tpublic overdueAt?: Date;\n\n\t@prop({ required: true, type: ServiceBookingFinance, _id: false })\n\tpublic finance!: ServiceBookingFinance;\n\n\t@prop({ required: true, type: ServiceBookingFinance, _id: false })\n\tpublic adjustedFinance!: ServiceBookingFinance;\n\n\t@prop({ type: () => ServiceBookingCancelllationDetails, _id: false })\n\tpublic cancellationDetails?: ServiceBookingCancelllationDetails;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isEndorseLossApplied?: boolean;\n\n\t@prop({ type: () => ServiceBookingEndorseLoss, _id: false })\n\tpublic endorseLossInformation?: ServiceBookingEndorseLoss;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isAdjusted?: boolean;\n\n\t@prop({ type: () => [ServiceBookingStatusTimeline], default: [] })\n\tpublic statusTimeline?: ServiceBookingStatusTimeline[];\n\n\t@prop({ type: Number })\n\tpublic bufferTime?: number; // minutes\n\n\t// Review feature\n\t@prop({ type: Boolean, default: false })\n\tpublic isReviewed?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isReviewNotificationSent?: boolean;\n\n\t@prop({\n\t\tref: () => Review,\n\t\tforeignField: 'serviceBooking',\n\t\tlocalField: '_id',\n\t})\n\tpublic reviews?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AAK,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,GAAG,MAAM,IAAA,yBAAU,EAAC,eAAY,EAAE,kBAAW,CAAC,OAAO,CAAC,CAAC;QACpE,CAAC;IACF,CAAC,CAAC;GACW,cAAc,CAuI1B","sourcesContent":["import { modelOptions, pre, prop, Ref, Severity } from '@typegoose/typegoose';\nimport { User } from './user.model';\nimport { Vendor } from './vendor.model';\nimport { ServiceBookingStatus, CounterType, ServiceType, SubServiceType } from '../../../utilities/enum';\nimport { Professional } from './professional.model';\nimport { ServiceCart } from './service-cart.model';\nimport { ServiceBookingFinance } from './embedded/service-booking-finance.model';\nimport {\n\tServiceBookingCancelllationDetails,\n\tServiceBookingEndorseLoss,\n} from './embedded/service-booking-cancellation-details.model';\nimport { ServiceBookingStatusTimeline } from './embedded/status-timeline.model';\nimport { generateId } from '../../../utilities/id-generator';\nimport { CounterModel, Review, VendorParent } from '.';\nimport { RegularOrderAddress } from './shared/address.model';\nimport { OrderSlotRange } from './shared/duration.model';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { ServiceBookingRefundInformation } from './embedded/service-booking-refund-information.model';\nimport { ServiceBookingReplacementInformation } from './embedded/service-booking-replacement-information.model';\nimport { ServiceFlag } from './service-flag.model';\n\n@modelOptions({\n\tschemaOptions: { collection: 'serviceBookings', timestamps: true },\n\toptions: { allowMixed: Severity.ALLOW },\n})\n@pre<ServiceBooking>('save', async function () {\n\tif (this.isNew) {\n\t\tthis.orderId = await generateId(CounterModel, CounterType.BOOKING);\n\t}\n})\nexport class ServiceBooking extends TimeStamps {\n\t@prop({ type: String, unique: true })\n\tpublic orderId?: string;\n\n\t@prop({ required: true, ref: () => User })\n\tpublic user!: Ref<User>;\n\n\t@prop({ required: true, ref: () => Vendor })\n\tpublic vendor!: Ref<Vendor>;\n\n\t@prop({ required: true, ref: () => VendorParent })\n\tpublic parent!: Ref<VendorParent>;\n\n\t@prop({ required: true, type: String, enum: ServiceType })\n\tpublic serviceType!: ServiceType;\n\n\t@prop({ type: String, enum: SubServiceType })\n\tpublic subServiceType?: SubServiceType;\n\n\t@prop({ required: true, ref: () => ServiceCart })\n\tpublic cart!: Ref<ServiceCart>;\n\n\t@prop({ required: true, type: () => RegularOrderAddress })\n\tpublic userAddress!: RegularOrderAddress;\n\n\t@prop({ required: true, type: OrderSlotRange, _id: false })\n\tpublic slotRange!: OrderSlotRange;\n\n\t@prop({ type: String, enum: ServiceBookingStatus, default: ServiceBookingStatus.PENDING })\n\tpublic status!: ServiceBookingStatus;\n\n\t@prop({ ref: () => Professional })\n\tpublic professionals?: Ref<Professional>[];\n\n\t@prop({ ref: () => Professional })\n\tpublic responsibleProfessional?: Ref<Professional>;\n\n\t@prop({ type: Date, default: new Date() })\n\tpublic processedAt?: Date;\n\n\t@prop({ type: Date })\n\tpublic placedAt?: Date;\n\n\t@prop({ type: Date })\n\tpublic startedAt?: Date;\n\n\t@prop({ type: Date })\n\tpublic estimatedCompletionAt?: Date;\n\n\t@prop({ type: Number })\n\tpublic estimatedCompletionInMinutes?: number;\n\n\t@prop({ type: Date })\n\tpublic completedAt?: Date;\n\n\t@prop({ type: Number })\n\tpublic actualCompletionInMinutes?: number;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isUrgentOrder?: boolean;\n\n\t@prop({ type: Date })\n\tpublic urgentAt?: Date;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isOverdue?: boolean;\n\n\t@prop({ type: Date })\n\tpublic overdueAt?: Date;\n\n\t@prop({ required: true, type: ServiceBookingFinance, _id: false })\n\tpublic finance!: ServiceBookingFinance;\n\n\t@prop({ required: true, type: ServiceBookingFinance, _id: false })\n\tpublic adjustedFinance!: ServiceBookingFinance;\n\n\t@prop({ type: () => ServiceBookingCancelllationDetails, _id: false })\n\tpublic cancellationDetails?: ServiceBookingCancelllationDetails;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isEndorseLossApplied?: boolean;\n\n\t@prop({ type: () => ServiceBookingEndorseLoss, _id: false })\n\tpublic endorseLossInformation?: ServiceBookingEndorseLoss;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isAdjusted?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isFlagged?: boolean;\n\n\t@prop({ type: Date })\n\tpublic flaggedAt?: Date;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isRefunded?: boolean;\n\n\t@prop({ type: ServiceBookingRefundInformation, _id: false })\n\tpublic refundInformation?: ServiceBookingRefundInformation;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isReplacement?: boolean;\n\n\t@prop({ type: () => ServiceBookingReplacementInformation, _id: false })\n\tpublic replacementInformation?: ServiceBookingReplacementInformation;\n\n\t@prop({ ref: () => ServiceBooking })\n\tpublic replacementBooking?: Ref<ServiceBooking>;\n\n\t@prop({ type: () => [ServiceBookingStatusTimeline], default: [] })\n\tpublic statusTimeline?: ServiceBookingStatusTimeline[];\n\n\t@prop({ type: Number })\n\tpublic bufferTime?: number; // minutes\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isReviewed?: boolean;\n\n\t@prop({ type: Boolean, default: false })\n\tpublic isReviewNotificationSent?: boolean;\n\n\t// Virtual field\n\t@prop({\n\t\tref: () => ServiceFlag,\n\t\tforeignField: 'serviceBooking',\n\t\tlocalField: '_id',\n\t})\n\tpublic flags?: Ref<ServiceFlag>[];\n\n\t@prop({\n\t\tref: () => Review,\n\t\tforeignField: 'serviceBooking',\n\t\tlocalField: '_id',\n\t})\n\tpublic reviews?: Ref<Review>[];\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Ref } from '@typegoose/typegoose';
|
|
2
|
+
import { ServiceFlagType, ServiceFlagReasonType } from '../../../utilities/enum';
|
|
3
|
+
import { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';
|
|
4
|
+
import { Admin } from './admin.model';
|
|
5
|
+
import { ServiceBooking } from './service-booking.model';
|
|
6
|
+
export declare class ServiceFlag extends TimeStamps {
|
|
7
|
+
serviceBooking: Ref<ServiceBooking>;
|
|
8
|
+
orderId: string;
|
|
9
|
+
flagType: ServiceFlagType;
|
|
10
|
+
reasonType?: ServiceFlagReasonType;
|
|
11
|
+
otherReason?: string;
|
|
12
|
+
flaggedBy?: Ref<Admin>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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.ServiceFlag = void 0;
|
|
13
|
+
const typegoose_1 = require("@typegoose/typegoose");
|
|
14
|
+
const enum_1 = require("../../../utilities/enum");
|
|
15
|
+
const defaultClasses_1 = require("@typegoose/typegoose/lib/defaultClasses");
|
|
16
|
+
const admin_model_1 = require("./admin.model");
|
|
17
|
+
const service_booking_model_1 = require("./service-booking.model");
|
|
18
|
+
let ServiceFlag = class ServiceFlag extends defaultClasses_1.TimeStamps {
|
|
19
|
+
serviceBooking;
|
|
20
|
+
orderId;
|
|
21
|
+
flagType;
|
|
22
|
+
reasonType;
|
|
23
|
+
otherReason;
|
|
24
|
+
flaggedBy;
|
|
25
|
+
};
|
|
26
|
+
exports.ServiceFlag = ServiceFlag;
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, typegoose_1.prop)({ required: true, ref: () => service_booking_model_1.ServiceBooking }),
|
|
29
|
+
__metadata("design:type", Object)
|
|
30
|
+
], ServiceFlag.prototype, "serviceBooking", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, typegoose_1.prop)({ required: true, type: String }),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], ServiceFlag.prototype, "orderId", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, typegoose_1.prop)({ required: true, type: String, enum: enum_1.ServiceFlagType }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], ServiceFlag.prototype, "flagType", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, typegoose_1.prop)({ type: String, enum: enum_1.ServiceFlagReasonType, default: enum_1.ServiceFlagReasonType.OTHER }),
|
|
41
|
+
__metadata("design:type", String)
|
|
42
|
+
], ServiceFlag.prototype, "reasonType", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, typegoose_1.prop)({ type: String }),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], ServiceFlag.prototype, "otherReason", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, typegoose_1.prop)({ ref: () => admin_model_1.Admin }),
|
|
49
|
+
__metadata("design:type", Object)
|
|
50
|
+
], ServiceFlag.prototype, "flaggedBy", void 0);
|
|
51
|
+
exports.ServiceFlag = ServiceFlag = __decorate([
|
|
52
|
+
(0, typegoose_1.modelOptions)({ schemaOptions: { collection: 'serviceFlags' } })
|
|
53
|
+
], ServiceFlag);
|
|
54
|
+
//# sourceMappingURL=service-flag.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-flag.model.js","sourceRoot":"/","sources":["libraries/mongo/models/service-flag.model.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAA+D;AAC/D,kDAAiF;AACjF,4EAAqE;AACrE,+CAAsC;AACtC,mEAAyD;AAGlD,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,2BAAU;IAEnC,cAAc,CAAuB;IAGrC,OAAO,CAAU;IAGjB,QAAQ,CAAmB;IAG3B,UAAU,CAAyB;IAGnC,WAAW,CAAU;IAGrB,SAAS,CAAc;CAC9B,CAAA;AAlBY,kCAAW;AAEhB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,sCAAc,EAAE,CAAC;;mDACR;AAGrC;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;4CACf;AAGjB;IADN,IAAA,gBAAI,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAe,EAAE,CAAC;;6CAC5B;AAG3B;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,4BAAqB,EAAE,OAAO,EAAE,4BAAqB,CAAC,KAAK,EAAE,CAAC;;+CAChD;AAGnC;IADN,IAAA,gBAAI,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;;gDACK;AAGrB;IADN,IAAA,gBAAI,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,mBAAK,EAAE,CAAC;;8CACG;sBAjBlB,WAAW;IADvB,IAAA,wBAAY,EAAC,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,cAAc,EAAE,EAAE,CAAC;GACnD,WAAW,CAkBvB","sourcesContent":["import { modelOptions, prop, Ref } from '@typegoose/typegoose';\nimport { ServiceFlagType, ServiceFlagReasonType } from '../../../utilities/enum';\nimport { TimeStamps } from '@typegoose/typegoose/lib/defaultClasses';\nimport { Admin } from './admin.model';\nimport { ServiceBooking } from './service-booking.model';\n\n@modelOptions({ schemaOptions: { collection: 'serviceFlags' } })\nexport class ServiceFlag extends TimeStamps {\n\t@prop({ required: true, ref: () => ServiceBooking })\n\tpublic serviceBooking!: Ref<ServiceBooking>;\n\n\t@prop({ required: true, type: String })\n\tpublic orderId!: string;\n\n\t@prop({ required: true, type: String, enum: ServiceFlagType })\n\tpublic flagType!: ServiceFlagType;\n\n\t@prop({ type: String, enum: ServiceFlagReasonType, default: ServiceFlagReasonType.OTHER })\n\tpublic reasonType?: ServiceFlagReasonType;\n\n\t@prop({ type: String })\n\tpublic otherReason?: string;\n\n\t@prop({ ref: () => Admin })\n\tpublic flaggedBy?: Ref<Admin>;\n}\n"]}
|
|
@@ -30,6 +30,9 @@ class SoftDelete {
|
|
|
30
30
|
}
|
|
31
31
|
static addQueryMiddleware(schema) {
|
|
32
32
|
const queryMiddleware = function () {
|
|
33
|
+
const options = this.getOptions();
|
|
34
|
+
if (options?.withDeleted)
|
|
35
|
+
return;
|
|
33
36
|
if (!this.getQuery().deletedAt) {
|
|
34
37
|
this.where({ deletedAt: null });
|
|
35
38
|
}
|
|
@@ -100,10 +103,13 @@ class SoftDelete {
|
|
|
100
103
|
return this.updateMany(filter, { deletedAt: null });
|
|
101
104
|
};
|
|
102
105
|
schema.statics.findWithDeleted = function (filter = {}) {
|
|
103
|
-
return this.find(filter);
|
|
106
|
+
return this.find(filter).setOptions({ withDeleted: true });
|
|
104
107
|
};
|
|
105
108
|
schema.statics.findDeleted = function (filter = {}) {
|
|
106
|
-
return this.find({
|
|
109
|
+
return this.find({
|
|
110
|
+
...filter,
|
|
111
|
+
deletedAt: { $ne: null },
|
|
112
|
+
}).setOptions({ withDeleted: true });
|
|
107
113
|
};
|
|
108
114
|
schema.statics.findRecordById = async function (data) {
|
|
109
115
|
const { _id, select, populate } = data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"soft-delete-plugin.js","sourceRoot":"/","sources":["libraries/mongo/plugins/soft-delete-plugin.ts"],"names":[],"mappings":";;;AACA,oDAAmF;AAyBnF,MAAa,cAAc;IAC1B,SAAS,CAAe;CACxB;AAFD,wCAEC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EoE","sourcesContent":["import { Schema, Query, Model } from 'mongoose';\nimport { getModelForClass, ReturnModelType, mongoose } from '@typegoose/typegoose';\nimport { AnyParamConstructor } from '@typegoose/typegoose/lib/types';\nimport { GetByIdInputDTO, GetOneQueryDTO } from '../../../utilities/validation';\n\n/**\n * Interface for models with soft delete capabilities\n */\nexport interface SoftDeleteModel<T> extends Model<T> {\n\tsoftDelete(_id: mongoose.Types.ObjectId): Promise<any>;\n\tsoftDeleteOne(filter: object): Promise<any>;\n\tsoftDeleteMany(filter?: object): Promise<any>;\n\tdeleteRecord(filter: object, softDelete: boolean): Promise<any>;\n\tdeleteRecords(filter: object, softDelete: boolean): Promise<any>;\n\trestore(_id: mongoose.Types.ObjectId): Promise<any>;\n\trestoreOne(filter: object): Promise<any>;\n\trestoreMany(filter?: object): Promise<any>;\n\tfindWithDeleted(filter?: object): any;\n\tfindDeleted(filter?: object): any;\n\tfindRecordById(data: GetByIdInputDTO): Promise<any>;\n\tfindOneRecord(data: GetOneQueryDTO): Promise<any>;\n}\n\n/**\n * Base class for models with soft delete functionality\n */\nexport class SoftDeleteBase {\n\tdeletedAt?: Date | null;\n}\n\n/**\n * SoftDelete class providing soft deletion functionality for mongoose models\n */\nexport class SoftDelete {\n\t/**\n\t * Apply soft delete plugin to a specific schema\n\t * @param schema Mongoose schema to enhance with soft delete functionality\n\t */\n\tpublic static applyToSchema(schema: Schema): void {\n\t\t// Add deletedAt field if it doesn't exist\n\t\tif (!schema.path('deletedAt')) {\n\t\t\tschema.add({\n\t\t\t\tdeletedAt: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\tdefault: null,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Add schema middleware\n\t\tthis.addQueryMiddleware(schema);\n\n\t\t// Add instance methods\n\t\tthis.addInstanceMethods(schema);\n\n\t\t// Add static methods\n\t\tthis.addStaticMethods(schema);\n\t}\n\n\t/**\n\t * Apply soft delete plugin globally to all mongoose schemas\n\t */\n\tpublic static applyGlobally(): void {\n\t\tconst mongoose = require('mongoose');\n\t\tmongoose.plugin((schema: Schema) => this.applyToSchema(schema));\n\t}\n\n\t/**\n\t * Create a model with soft delete capabilities and proper TypeScript types\n\t * @param modelClass The class to create a model from\n\t * @returns A model with soft delete functionality\n\t */\n\tpublic static createModel<T extends SoftDeleteBase>(\n\t\tmodelClass: AnyParamConstructor<T>\n\t): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> {\n\t\tconst model = getModelForClass(modelClass);\n\t\treturn model as any; // The plugin adds the methods, we just need to tell TypeScript they exist\n\t}\n\n\t/**\n\t * Add query middleware to filter out soft-deleted documents\n\t * @param schema Schema to add middleware to\n\t */\n\tprivate static addQueryMiddleware(schema: Schema): void {\n\t\tconst queryMiddleware = function (this: Query<any, any>) {\n\t\t\tif (!this.getQuery().deletedAt) {\n\t\t\t\tthis.where({ deletedAt: null });\n\t\t\t}\n\t\t};\n\n\t\t// Apply middleware to relevant query methods\n\t\tschema.pre('find', queryMiddleware);\n\t\tschema.pre('findOne', queryMiddleware);\n\t\tschema.pre('findOneAndUpdate', queryMiddleware);\n\t\tschema.pre('findOneAndDelete', queryMiddleware);\n\t\tschema.pre('findOneAndReplace', queryMiddleware);\n\t\tschema.pre('updateOne', queryMiddleware);\n\t\tschema.pre('updateMany', queryMiddleware);\n\t\t// TypeScript workaround for count hook\n\t\t(schema as any).pre('count', queryMiddleware);\n\t\tschema.pre('countDocuments', queryMiddleware);\n\t\t(schema as any).pre('exists', queryMiddleware);\n\n\t\t// Override findById to respect soft delete\n\t\tschema.statics.findById = function (_id: mongoose.Types.ObjectId, projection?: any, options?: any) {\n\t\t\treturn this.findOne({ _id, deletedAt: null }, projection, options);\n\t\t};\n\t}\n\n\t/**\n\t * Add instance methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addInstanceMethods(schema: Schema): void {\n\t\tschema.methods.softDelete = function () {\n\t\t\tthis.deletedAt = new Date();\n\t\t\treturn this.save();\n\t\t};\n\n\t\tschema.methods.restore = function () {\n\t\t\tthis.deletedAt = null;\n\t\t\treturn this.save();\n\t\t};\n\t}\n\n\t/**\n\t * Add static methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addStaticMethods(schema: Schema): void {\n\t\tschema.statics.softDelete = async function (_id: mongoose.Types.ObjectId) {\n\t\t\tconst result = await this.updateOne({ _id }, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteOne = async function (filter: object) {\n\t\t\tconst result = await this.updateOne(filter, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: new Date() });\n\t\t};\n\n\t\tschema.statics.deleteRecord = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateOne({ ...filter, deletedAt: null }, { deletedAt: new Date() });\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteOne(filter);\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.deleteRecords = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateMany({ ...filter, deletedAt: null }, { deletedAt: new Date() });\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteMany(filter);\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.restore = function (_id: mongoose.Types.ObjectId) {\n\t\t\treturn this.updateOne({ _id }, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreOne = function (filter: object) {\n\t\t\treturn this.updateOne(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.findWithDeleted = function (filter = {}) {\n\t\t\treturn this.find(filter);\n\t\t};\n\n\t\tschema.statics.findDeleted = function (filter = {}) {\n\t\t\treturn this.find({ ...filter, deletedAt: { $ne: null } });\n\t\t};\n\n\t\tschema.statics.findRecordById = async function (data: GetByIdInputDTO) {\n\t\t\tconst { _id, select, populate } = data;\n\n\t\t\tlet result = this.findById(_id);\n\n\t\t\tif (select) {\n\t\t\t\tresult = result.select(select) as any;\n\t\t\t}\n\n\t\t\tif (populate) {\n\t\t\t\tresult = result.populate(populate);\n\t\t\t}\n\n\t\t\treturn await result.exec();\n\t\t};\n\n\t\tschema.statics.findOneRecord = async function (data: GetOneQueryDTO) {\n\t\t\tconst { query, select, populate } = data;\n\n\t\t\tlet result = this.findOne(query || {});\n\n\t\t\tif (select) {\n\t\t\t\tresult = result.select(select) as any;\n\t\t\t}\n\n\t\t\tif (populate) {\n\t\t\t\tresult = result.populate(populate);\n\t\t\t}\n\n\t\t\treturn await result.exec();\n\t\t};\n\t}\n}\n\n// Export convenience functions with the same names as before for backward compatibility\nexport const softDeletePlugin = (schema: Schema): void => SoftDelete.applyToSchema(schema);\nexport const applySoftDeletePlugin = (): void => SoftDelete.applyGlobally();\nexport const createSoftDeleteModel = <T extends SoftDeleteBase>(\n\tmodelClass: AnyParamConstructor<T>\n): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> => SoftDelete.createModel(modelClass);\n"]}
|
|
1
|
+
{"version":3,"file":"soft-delete-plugin.js","sourceRoot":"/","sources":["libraries/mongo/plugins/soft-delete-plugin.ts"],"names":[],"mappings":";;;AACA,oDAAmF;AAyBnF,MAAa,cAAc;IAC1B,SAAS,CAAe;CACxB;AAFD,wCAEC;AAKD,MAAa,UAAU;IAKf,MAAM,CAAC,aAAa,CAAC,MAAc;QAEzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC;gBACV,SAA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UAAU,CAAC,CAAC;AAFzF,QAAA,qBAAqB,yBAEoE","sourcesContent":["import { Schema, Query, Model } from 'mongoose';\nimport { getModelForClass, ReturnModelType, mongoose } from '@typegoose/typegoose';\nimport { AnyParamConstructor } from '@typegoose/typegoose/lib/types';\nimport { GetByIdInputDTO, GetOneQueryDTO } from '../../../utilities/validation';\n\n/**\n * Interface for models with soft delete capabilities\n */\nexport interface SoftDeleteModel<T> extends Model<T> {\n\tsoftDelete(_id: mongoose.Types.ObjectId): Promise<any>;\n\tsoftDeleteOne(filter: object): Promise<any>;\n\tsoftDeleteMany(filter?: object): Promise<any>;\n\tdeleteRecord(filter: object, softDelete: boolean): Promise<any>;\n\tdeleteRecords(filter: object, softDelete: boolean): Promise<any>;\n\trestore(_id: mongoose.Types.ObjectId): Promise<any>;\n\trestoreOne(filter: object): Promise<any>;\n\trestoreMany(filter?: object): Promise<any>;\n\tfindWithDeleted(filter?: object): any;\n\tfindDeleted(filter?: object): any;\n\tfindRecordById(data: GetByIdInputDTO): Promise<any>;\n\tfindOneRecord(data: GetOneQueryDTO): Promise<any>;\n}\n\n/**\n * Base class for models with soft delete functionality\n */\nexport class SoftDeleteBase {\n\tdeletedAt?: Date | null;\n}\n\n/**\n * SoftDelete class providing soft deletion functionality for mongoose models\n */\nexport class SoftDelete {\n\t/**\n\t * Apply soft delete plugin to a specific schema\n\t * @param schema Mongoose schema to enhance with soft delete functionality\n\t */\n\tpublic static applyToSchema(schema: Schema): void {\n\t\t// Add deletedAt field if it doesn't exist\n\t\tif (!schema.path('deletedAt')) {\n\t\t\tschema.add({\n\t\t\t\tdeletedAt: {\n\t\t\t\t\ttype: Date,\n\t\t\t\t\tdefault: null,\n\t\t\t\t},\n\t\t\t});\n\t\t}\n\n\t\t// Add schema middleware\n\t\tthis.addQueryMiddleware(schema);\n\n\t\t// Add instance methods\n\t\tthis.addInstanceMethods(schema);\n\n\t\t// Add static methods\n\t\tthis.addStaticMethods(schema);\n\t}\n\n\t/**\n\t * Apply soft delete plugin globally to all mongoose schemas\n\t */\n\tpublic static applyGlobally(): void {\n\t\tconst mongoose = require('mongoose');\n\t\tmongoose.plugin((schema: Schema) => this.applyToSchema(schema));\n\t}\n\n\t/**\n\t * Create a model with soft delete capabilities and proper TypeScript types\n\t * @param modelClass The class to create a model from\n\t * @returns A model with soft delete functionality\n\t */\n\tpublic static createModel<T extends SoftDeleteBase>(\n\t\tmodelClass: AnyParamConstructor<T>\n\t): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> {\n\t\tconst model = getModelForClass(modelClass);\n\t\treturn model as any; // The plugin adds the methods, we just need to tell TypeScript they exist\n\t}\n\n\t/**\n\t * Add query middleware to filter out soft-deleted documents\n\t * @param schema Schema to add middleware to\n\t */\n\tprivate static addQueryMiddleware(schema: Schema): void {\n\t\tconst queryMiddleware = function (this: Query<any, any>) {\n\t\t\tconst options = this.getOptions();\n\n\t\t\tif (options?.withDeleted) return;\n\n\t\t\tif (!this.getQuery().deletedAt) {\n\t\t\t\tthis.where({ deletedAt: null });\n\t\t\t}\n\t\t};\n\n\t\t// Apply middleware to relevant query methods\n\t\tschema.pre('find', queryMiddleware);\n\t\tschema.pre('findOne', queryMiddleware);\n\t\tschema.pre('findOneAndUpdate', queryMiddleware);\n\t\tschema.pre('findOneAndDelete', queryMiddleware);\n\t\tschema.pre('findOneAndReplace', queryMiddleware);\n\t\tschema.pre('updateOne', queryMiddleware);\n\t\tschema.pre('updateMany', queryMiddleware);\n\t\t// TypeScript workaround for count hook\n\t\t(schema as any).pre('count', queryMiddleware);\n\t\tschema.pre('countDocuments', queryMiddleware);\n\t\t(schema as any).pre('exists', queryMiddleware);\n\n\t\t// Override findById to respect soft delete\n\t\tschema.statics.findById = function (_id: mongoose.Types.ObjectId, projection?: any, options?: any) {\n\t\t\treturn this.findOne({ _id, deletedAt: null }, projection, options);\n\t\t};\n\t}\n\n\t/**\n\t * Add instance methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addInstanceMethods(schema: Schema): void {\n\t\tschema.methods.softDelete = function () {\n\t\t\tthis.deletedAt = new Date();\n\t\t\treturn this.save();\n\t\t};\n\n\t\tschema.methods.restore = function () {\n\t\t\tthis.deletedAt = null;\n\t\t\treturn this.save();\n\t\t};\n\t}\n\n\t/**\n\t * Add static methods for soft delete operations\n\t * @param schema Schema to add methods to\n\t */\n\tprivate static addStaticMethods(schema: Schema): void {\n\t\tschema.statics.softDelete = async function (_id: mongoose.Types.ObjectId) {\n\t\t\tconst result = await this.updateOne({ _id }, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteOne = async function (filter: object) {\n\t\t\tconst result = await this.updateOne(filter, { deletedAt: new Date() });\n\t\t\treturn result.modifiedCount > 0;\n\t\t};\n\n\t\tschema.statics.softDeleteMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: new Date() });\n\t\t};\n\n\t\tschema.statics.deleteRecord = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateOne({ ...filter, deletedAt: null }, { deletedAt: new Date() });\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteOne(filter);\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.deleteRecords = async function (filter: object, softDelete: boolean) {\n\t\t\tif (softDelete) {\n\t\t\t\tconst result = await this.updateMany({ ...filter, deletedAt: null }, { deletedAt: new Date() });\n\t\t\t\treturn Boolean(result.modifiedCount);\n\t\t\t} else {\n\t\t\t\tconst result = await this.deleteMany(filter);\n\t\t\t\treturn Boolean(result.deletedCount);\n\t\t\t}\n\t\t};\n\n\t\tschema.statics.restore = function (_id: mongoose.Types.ObjectId) {\n\t\t\treturn this.updateOne({ _id }, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreOne = function (filter: object) {\n\t\t\treturn this.updateOne(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.restoreMany = function (filter = {}) {\n\t\t\treturn this.updateMany(filter, { deletedAt: null });\n\t\t};\n\n\t\tschema.statics.findWithDeleted = function (filter = {}) {\n\t\t\treturn this.find(filter).setOptions({ withDeleted: true });\n\t\t};\n\n\t\tschema.statics.findDeleted = function (filter = {}) {\n\t\t\treturn this.find({\n\t\t\t\t...filter,\n\t\t\t\tdeletedAt: { $ne: null },\n\t\t\t}).setOptions({ withDeleted: true });\n\t\t};\n\n\t\tschema.statics.findRecordById = async function (data: GetByIdInputDTO) {\n\t\t\tconst { _id, select, populate } = data;\n\n\t\t\tlet result = this.findById(_id);\n\n\t\t\tif (select) {\n\t\t\t\tresult = result.select(select) as any;\n\t\t\t}\n\n\t\t\tif (populate) {\n\t\t\t\tresult = result.populate(populate);\n\t\t\t}\n\n\t\t\treturn await result.exec();\n\t\t};\n\n\t\tschema.statics.findOneRecord = async function (data: GetOneQueryDTO) {\n\t\t\tconst { query, select, populate } = data;\n\n\t\t\tlet result = this.findOne(query || {});\n\n\t\t\tif (select) {\n\t\t\t\tresult = result.select(select) as any;\n\t\t\t}\n\n\t\t\tif (populate) {\n\t\t\t\tresult = result.populate(populate);\n\t\t\t}\n\n\t\t\treturn await result.exec();\n\t\t};\n\t}\n}\n\n// Export convenience functions with the same names as before for backward compatibility\nexport const softDeletePlugin = (schema: Schema): void => SoftDelete.applyToSchema(schema);\nexport const applySoftDeletePlugin = (): void => SoftDelete.applyGlobally();\nexport const createSoftDeleteModel = <T extends SoftDeleteBase>(\n\tmodelClass: AnyParamConstructor<T>\n): SoftDeleteModel<T> & ReturnModelType<AnyParamConstructor<T>> => SoftDelete.createModel(modelClass);\n"]}
|
package/dist/types/README.md
CHANGED
package/dist/types/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lyxa.ai/types",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.51-beta.0",
|
|
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",
|
|
@@ -857,6 +857,14 @@ export declare enum FlagReasonType {
|
|
|
857
857
|
HIGH_VALUE_FIRST_ORDER = "high_value_first_order",
|
|
858
858
|
ADJUSTED_ORDER_REQUEST_IGNORED = "adjusted_order_request_ignored"
|
|
859
859
|
}
|
|
860
|
+
export declare enum ServiceFlagType {
|
|
861
|
+
REPLACEMENT = "replacement",
|
|
862
|
+
REFUNDED = "refunded"
|
|
863
|
+
}
|
|
864
|
+
export declare enum ServiceFlagReasonType {
|
|
865
|
+
INCOMPLETE_SERVICE = "incomplete_service",
|
|
866
|
+
OTHER = "other"
|
|
867
|
+
}
|
|
860
868
|
export declare enum UrgentOrderReasons {
|
|
861
869
|
SHOP_INACTION = "shop_inaction",
|
|
862
870
|
RIDER_INACTION = "rider_inaction",
|
|
@@ -970,10 +978,6 @@ export declare enum AppAppearanceType {
|
|
|
970
978
|
SPLASH = "splash",
|
|
971
979
|
HEADERS = "headers"
|
|
972
980
|
}
|
|
973
|
-
export declare enum ServiceBookingActionType {
|
|
974
|
-
RESCHEDULE = "reschedule",
|
|
975
|
-
REFUND = "refund"
|
|
976
|
-
}
|
|
977
981
|
export declare enum DateFormatType {
|
|
978
982
|
YYYY_MM_DD = "YYYY-MM-DD",
|
|
979
983
|
DD_MM_YYYY = "DD-MM-YYYY",
|