@doctocar/tooling 0.3.1-20 → 0.3.1-22
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/emails/types/customer/CustomerConfirmedOrderCancelledEmailData.type.d.ts +1 -1
- package/dist/emails/types/customer/CustomerOrderReviewRequestedEmailData.type.d.ts +1 -1
- package/dist/emails/types/customer/CustomerServiceCompletedByProfessionalEmailData.type.d.ts +1 -1
- package/dist/emails/types/customer/CustomerServiceStartedEmailData.type.d.ts +1 -1
- package/dist/emails/types/customer/CustomerUpcomingOrderReminderEmailData.type.d.ts +1 -1
- package/dist/emails/types/professional/ProfessionalConfirmedOrderCancelledEmailData.type.d.ts +1 -1
- package/dist/emails/types/professional/ProfessionalOrderIssueReportedConfirmationEmailData.type.d.ts +1 -1
- package/dist/emails/types/professional/ProfessionalOrderNewMessageReceivedEmailData.type.d.ts +1 -1
- package/dist/emails/types/professional/ProfessionalServiceCompletedByProfessionalEmailData.type.d.ts +1 -1
- package/dist/errors/enums/cloudFunctions/orders/CancelConfirmedOrInProgressOrderErrorCodes.enum.d.ts +1 -1
- package/dist/errors/enums/cloudFunctions/orders/CancelConfirmedOrInProgressOrderErrorCodes.enum.js +1 -1
- package/dist/errors/enums/cloudFunctions/orders/ConfirmServiceCompletionByServiceProviderErrorCodes.enum.d.ts +7 -0
- package/dist/errors/enums/cloudFunctions/orders/ConfirmServiceCompletionByServiceProviderErrorCodes.enum.js +11 -0
- package/dist/errors/enums/cloudFunctions/orders/StartConfirmedOrderByServiceProviderErrorCodes.enum.d.ts +6 -0
- package/dist/errors/enums/cloudFunctions/orders/StartConfirmedOrderByServiceProviderErrorCodes.enum.js +10 -0
- package/dist/errors/enums/cloudFunctions/orders/index.d.ts +2 -2
- package/dist/errors/enums/cloudFunctions/orders/index.js +2 -2
- package/dist/errors/enums/cloudFunctions/serviceProviderUsers/DeleteServiceProviderUserServiceErrorCodes.enum.d.ts +1 -1
- package/dist/errors/enums/cloudFunctions/serviceProviderUsers/DeleteServiceProviderUserServiceErrorCodes.enum.js +1 -1
- package/dist/errors/enums/cloudFunctions/serviceProviderUsers/UpdateServiceProviderUserServiceErrorCodes.enum.d.ts +1 -1
- package/dist/errors/enums/cloudFunctions/serviceProviderUsers/UpdateServiceProviderUserServiceErrorCodes.enum.js +1 -1
- package/dist/firebase/cloudFunctions/enums/OnCallCloudFunctionsNames.enum.d.ts +2 -2
- package/dist/firebase/cloudFunctions/enums/OnCallCloudFunctionsNames.enum.js +2 -2
- package/dist/firebase/cloudFunctions/enums/TaskCloudFunctionsNames.enum.d.ts +1 -1
- package/dist/firebase/cloudFunctions/enums/TaskCloudFunctionsNames.enum.js +1 -1
- package/dist/firebase/cloudFunctions/maps/OnCallCloudFunctionsTypeMappings.map.d.ts +7 -7
- package/dist/firebase/cloudFunctions/types/orders/ConfirmServiceCompletionByServiceProviderRequestData.type.d.ts +4 -0
- package/dist/firebase/cloudFunctions/types/orders/ConfirmServiceCompletionByServiceProviderRequestData.type.js +2 -0
- package/dist/firebase/cloudFunctions/types/orders/ConfirmServiceCompletionByServiceProviderResponseData.type.d.ts +1 -0
- package/dist/firebase/cloudFunctions/types/orders/ConfirmServiceCompletionByServiceProviderResponseData.type.js +2 -0
- package/dist/firebase/cloudFunctions/types/orders/StartConfirmedOrderByServiceProviderRequestData.type.d.ts +4 -0
- package/dist/firebase/cloudFunctions/types/orders/StartConfirmedOrderByServiceProviderRequestData.type.js +2 -0
- package/dist/firebase/cloudFunctions/types/orders/StartConfirmedOrderByServiceProviderResponseData.type.d.ts +1 -0
- package/dist/firebase/cloudFunctions/types/orders/StartConfirmedOrderByServiceProviderResponseData.type.js +2 -0
- package/dist/firebase/cloudFunctions/types/orders/index.d.ts +4 -4
- package/dist/firebase/cloudFunctions/types/orders/index.js +4 -4
- package/dist/firebase/cloudFunctions/types/users/serviceProviderUsers/UpdateServiceProviderUserServiceRequestData.type.d.ts +2 -2
- package/dist/firebase/firestore/constants/index.d.ts +4 -4
- package/dist/firebase/firestore/constants/index.js +4 -4
- package/dist/firebase/firestore/constants/providerLocationServiceMaxRadiusInKM.constant.d.ts +1 -0
- package/dist/firebase/firestore/constants/providerLocationServiceMaxRadiusInKM.constant.js +4 -0
- package/dist/firebase/firestore/constants/providerLocationServiceMinRadiusInKM.constant.d.ts +1 -0
- package/dist/firebase/firestore/constants/providerLocationServiceMinRadiusInKM.constant.js +4 -0
- package/dist/firebase/firestore/constants/providerServiceMinimumDurationIncrementInMinutes.constant.d.ts +1 -0
- package/dist/firebase/firestore/constants/providerServiceMinimumDurationIncrementInMinutes.constant.js +4 -0
- package/dist/firebase/firestore/constants/providerServiceMinimumPriceIncrementInCents.constant.d.ts +1 -0
- package/dist/firebase/firestore/constants/providerServiceMinimumPriceIncrementInCents.constant.js +4 -0
- package/dist/firebase/firestore/enums/FirestoreCollections.enum.d.ts +1 -1
- package/dist/firebase/firestore/enums/FirestoreCollections.enum.js +1 -1
- package/dist/firebase/firestore/enums/orders/OrderCancellationByTypes.enum.d.ts +1 -1
- package/dist/firebase/firestore/enums/orders/OrderCancellationByTypes.enum.js +1 -1
- package/dist/firebase/firestore/enums/orders/OrderServiceProviderCancellationReason.enum.d.ts +7 -7
- package/dist/firebase/firestore/enums/orders/OrderServiceProviderCancellationReason.enum.js +7 -7
- package/dist/firebase/firestore/enums/orders/dispute/OrderDisputeOpenedBy.enum.d.ts +1 -1
- package/dist/firebase/firestore/enums/orders/dispute/OrderDisputeOpenedBy.enum.js +1 -1
- package/dist/firebase/firestore/enums/orders/index.d.ts +1 -1
- package/dist/firebase/firestore/enums/orders/index.js +1 -1
- package/dist/firebase/firestore/enums/ordersIssues/CustomerOrderIssueReason.enum.d.ts +2 -2
- package/dist/firebase/firestore/enums/ordersIssues/CustomerOrderIssueReason.enum.js +2 -2
- package/dist/firebase/firestore/enums/ordersIssues/ServiceProviderOrderIssueReason.enum.d.ts +10 -0
- package/dist/firebase/firestore/enums/ordersIssues/ServiceProviderOrderIssueReason.enum.js +14 -0
- package/dist/firebase/firestore/enums/ordersIssues/index.d.ts +1 -1
- package/dist/firebase/firestore/enums/ordersIssues/index.js +1 -1
- package/dist/firebase/firestore/enums/users/professionals/ServiceProviderBadgesTypes.enum.d.ts +3 -0
- package/dist/firebase/firestore/enums/users/professionals/ServiceProviderBadgesTypes.enum.js +7 -0
- package/dist/firebase/firestore/enums/users/professionals/index.d.ts +1 -1
- package/dist/firebase/firestore/enums/users/professionals/index.js +1 -1
- package/dist/firebase/firestore/maps/FirestoreCollectionDocumentTypeMap.d.ts +2 -2
- package/dist/firebase/firestore/types/index.d.ts +1 -1
- package/dist/firebase/firestore/types/index.js +1 -1
- package/dist/firebase/firestore/types/order/FirestoreOrderCancellationReason.type.d.ts +2 -2
- package/dist/firebase/firestore/types/ordersIssues/OrderIssueReason.type.d.ts +2 -2
- package/dist/firebase/firestore/types/ordersReviews/FirestoreOrderReviewDocument.type.d.ts +1 -1
- package/dist/firebase/firestore/types/serviceProviderUserPublicDocument/FirestoreServiceProviderUserPublicDocument.type.d.ts +49 -0
- package/dist/firebase/firestore/types/serviceProviderUserPublicDocument/FirestoreServiceProviderUserPublicDocument.type.js +2 -0
- package/dist/firebase/firestore/types/serviceProviderUserPublicDocument/FirestoreServiceProviderUserPublicDocumentReviewAggregates.type.d.ts +4 -0
- package/dist/firebase/firestore/types/serviceProviderUserPublicDocument/FirestoreServiceProviderUserPublicDocumentReviewAggregates.type.js +2 -0
- package/dist/firebase/firestore/types/serviceProviderUserPublicDocument/FirestoreServiceProviderUserPublicDocumentServicesLocation.type.d.ts +4 -0
- package/dist/firebase/firestore/types/serviceProviderUserPublicDocument/FirestoreServiceProviderUserPublicDocumentServicesLocation.type.js +2 -0
- package/dist/firebase/firestore/types/serviceProviderUserPublicDocument/index.d.ts +3 -0
- package/dist/firebase/firestore/types/serviceProviderUserPublicDocument/index.js +19 -0
- package/dist/firebase/firestore/types/services/ProviderService.type.d.ts +8 -0
- package/dist/firebase/firestore/types/services/ProviderService.type.js +2 -0
- package/dist/firebase/firestore/types/services/ServiceProviderService.type.d.ts +8 -0
- package/dist/firebase/firestore/types/services/ServiceProviderService.type.js +2 -0
- package/dist/firebase/firestore/types/services/index.d.ts +1 -1
- package/dist/firebase/firestore/types/services/index.js +1 -1
- package/dist/firebase/firestore/utils/dataValidators/services/__tests__/isValidProfessionalService.test.js +11 -11
- package/dist/firebase/firestore/utils/dataValidators/services/__tests__/isValidProviderService.test.d.ts +1 -0
- package/dist/firebase/firestore/utils/dataValidators/services/__tests__/isValidProviderService.test.js +172 -0
- package/dist/firebase/firestore/utils/dataValidators/services/__tests__/isValidServicePricingAndDurationForVehicle.test.js +9 -9
- package/dist/firebase/firestore/utils/dataValidators/services/index.d.ts +1 -1
- package/dist/firebase/firestore/utils/dataValidators/services/index.js +1 -1
- package/dist/firebase/firestore/utils/dataValidators/services/isValidProfessionalService.d.ts +1 -1
- package/dist/firebase/firestore/utils/dataValidators/services/isValidProfessionalService.js +13 -13
- package/dist/firebase/firestore/utils/dataValidators/services/isValidProviderService.d.ts +2 -0
- package/dist/firebase/firestore/utils/dataValidators/services/isValidProviderService.js +42 -0
- package/dist/firebase/firestore/utils/dataValidators/services/isValidServicePricingAndDurationForVehicle.js +2 -2
- package/dist/firebase/firestore/utils/dataValidators/services/types/IsValidProfessionalServiceParams.type.d.ts +2 -2
- package/dist/firebase/firestore/utils/dataValidators/services/types/IsValidProviderServiceParams.type.d.ts +6 -0
- package/dist/firebase/firestore/utils/dataValidators/services/types/IsValidProviderServiceParams.type.js +2 -0
- package/dist/firebase/firestore/utils/dataValidators/services/types/index.d.ts +1 -1
- package/dist/firebase/firestore/utils/dataValidators/services/types/index.js +1 -1
- package/dist/firebase/firestore/utils/order/__tests__/buildOrderServicePreTaxLinesAndServicesDetails.test.js +13 -13
- package/dist/firebase/firestore/utils/order/buildOrderServicePreTaxLinesAndServicesDetails.d.ts +1 -1
- package/dist/firebase/firestore/utils/order/buildOrderServicePreTaxLinesAndServicesDetails.js +2 -2
- package/dist/firebase/firestore/utils/order/types/BuildOrderServicePreTaxLinesAndServicesDetailsProps.type.d.ts +2 -2
- package/dist/firebase/firestore/utils/reviews/__tests__/getAverageRatingFromReviewAggregates.test.d.ts +1 -0
- package/dist/firebase/firestore/utils/reviews/__tests__/getAverageRatingFromReviewAggregates.test.js +97 -0
- package/dist/firebase/firestore/utils/reviews/getAverageRatingFromReviewAggregates.d.ts +2 -0
- package/dist/firebase/firestore/utils/reviews/getAverageRatingFromReviewAggregates.js +13 -0
- package/dist/firebase/firestore/utils/reviews/index.d.ts +1 -1
- package/dist/firebase/firestore/utils/reviews/index.js +1 -1
- package/dist/firebase/firestore/utils/services/__tests__/computeTotalServiceProviderServiceDurationInMinutesForVehicleType.test.d.ts +1 -0
- package/dist/firebase/firestore/utils/services/__tests__/computeTotalServiceProviderServiceDurationInMinutesForVehicleType.test.js +101 -0
- package/dist/firebase/firestore/utils/services/__tests__/createServiceVehicleComboKey.test.js +4 -4
- package/dist/firebase/firestore/utils/services/__tests__/getBookableServiceProviderServicesForVehicleType.test.js +49 -49
- package/dist/firebase/firestore/utils/services/__tests__/getServiceProviderActiveServicePricingAndDurationForVehicleOrThrow.test.js +32 -32
- package/dist/firebase/firestore/utils/services/computeTotalServiceProviderServiceDurationInMinutesForVehicleType.d.ts +2 -0
- package/dist/firebase/firestore/utils/services/computeTotalServiceProviderServiceDurationInMinutesForVehicleType.js +18 -0
- package/dist/firebase/firestore/utils/services/getBookableServiceProviderServicesForVehicleType.d.ts +3 -3
- package/dist/firebase/firestore/utils/services/getBookableServiceProviderServicesForVehicleType.js +11 -11
- package/dist/firebase/firestore/utils/services/getServiceProviderActiveServicePricingAndDurationForVehicleOrThrow.d.ts +1 -1
- package/dist/firebase/firestore/utils/services/getServiceProviderActiveServicePricingAndDurationForVehicleOrThrow.js +2 -2
- package/dist/firebase/firestore/utils/services/index.d.ts +1 -1
- package/dist/firebase/firestore/utils/services/index.js +1 -1
- package/dist/firebase/firestore/utils/services/types/ComputeTotalServiceProviderServiceDurationInMinutesForVehicleTypeArgs.type.d.ts +7 -0
- package/dist/firebase/firestore/utils/services/types/ComputeTotalServiceProviderServiceDurationInMinutesForVehicleTypeArgs.type.js +2 -0
- package/dist/firebase/firestore/utils/services/types/GetBookableServiceProviderServicesForVehicleTypeParams.type.d.ts +2 -2
- package/dist/firebase/firestore/utils/services/types/GetServiceProviderActiveServicePricingAndDurationForVehicleOrThrowParams.type.d.ts +2 -2
- package/dist/firebase/firestore/utils/services/types/index.d.ts +1 -1
- package/dist/firebase/firestore/utils/services/types/index.js +1 -1
- package/dist/firebase/firestore/utils/stubs/index.d.ts +1 -1
- package/dist/firebase/firestore/utils/stubs/index.js +1 -1
- package/dist/firebase/firestore/utils/stubs/ordersReviews/firestoreOrderReviewDocumentStub.js +1 -1
- package/dist/firebase/firestore/utils/stubs/serviceProviderUserPublicDocument/firestoreServiceProviderUserPublicDocumentStub.d.ts +2 -0
- package/dist/firebase/firestore/utils/stubs/serviceProviderUserPublicDocument/firestoreServiceProviderUserPublicDocumentStub.js +44 -0
- package/dist/firebase/firestore/utils/stubs/serviceProviderUserPublicDocument/index.d.ts +1 -0
- package/dist/firebase/firestore/utils/stubs/serviceProviderUserPublicDocument/index.js +17 -0
- package/dist/firebase/firestore/utils/stubs/services/index.d.ts +1 -1
- package/dist/firebase/firestore/utils/stubs/services/index.js +1 -1
- package/dist/firebase/firestore/utils/stubs/services/pricingAndDurationForVehicleStub.js +2 -2
- package/dist/firebase/firestore/utils/stubs/services/providerServiceStub.d.ts +5 -0
- package/dist/firebase/firestore/utils/stubs/services/providerServiceStub.js +21 -0
- package/dist/firebase/firestore/utils/stubs/services/serviceProviderServiceStub.d.ts +5 -0
- package/dist/firebase/firestore/utils/stubs/services/serviceProviderServiceStub.js +21 -0
- package/dist/firebase/storage/enums/FirebaseStorageBasePaths.enum.js +1 -1
- package/dist/gcp/cloudTask/enums/CloudTasksQueueName.enum.d.ts +1 -1
- package/dist/gcp/cloudTask/enums/CloudTasksQueueName.enum.js +1 -1
- package/dist/gcp/cloudTask/maps/CloudTaskEnvelopeMap.map.d.ts +2 -2
- package/dist/gcp/cloudTask/types/OnTaskRecomputeServiceProviderAvailabilityEnvelope.type.d.ts +1 -1
- package/dist/gcp/cloudTask/types/index.d.ts +1 -1
- package/dist/gcp/cloudTask/types/index.js +1 -1
- package/dist/gcp/cloudTask/utils/stubs/index.d.ts +1 -1
- package/dist/gcp/cloudTask/utils/stubs/index.js +1 -1
- package/dist/gcp/cloudTask/utils/stubs/onTaskRecomputeServiceProviderAvailabilityEnvelopeStub.js +1 -1
- package/dist/pricing/__tests__/calculateInvoiceTotalWithTax.util.test.js +3 -3
- package/dist/stripe/types/StripeCustomServiceProviderPayoutMetadata.type.d.ts +5 -0
- package/dist/stripe/types/StripeCustomServiceProviderPayoutMetadata.type.js +2 -0
- package/dist/stripe/types/index.d.ts +1 -1
- package/dist/stripe/types/index.js +1 -1
- package/package.json +1 -1
|
@@ -15,4 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./isValidServicePricingAndDurationForVehicle"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./isValidProviderService"), exports);
|
package/dist/firebase/firestore/utils/dataValidators/services/isValidProfessionalService.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { IsValidProfessionalServiceParams } from "./types";
|
|
2
|
-
export declare function isValidProfessionalService({
|
|
2
|
+
export declare function isValidProfessionalService({ providerService, countryServicePublicConfig, }: IsValidProfessionalServiceParams): Promise<void>;
|
|
@@ -4,21 +4,21 @@ exports.isValidProfessionalService = isValidProfessionalService;
|
|
|
4
4
|
const errors_1 = require("../../../../../errors");
|
|
5
5
|
const enums_1 = require("../../../enums");
|
|
6
6
|
const isValidServicePricingAndDurationForVehicle_1 = require("./isValidServicePricingAndDurationForVehicle");
|
|
7
|
-
async function isValidProfessionalService({
|
|
8
|
-
if (
|
|
9
|
-
typeof
|
|
7
|
+
async function isValidProfessionalService({ providerService, countryServicePublicConfig, }) {
|
|
8
|
+
if (providerService.isActive === undefined ||
|
|
9
|
+
typeof providerService.isActive !== "boolean") {
|
|
10
10
|
throw new errors_1.DoctoCarError("Professional service is active is required and must be a boolean", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_IS_ACTIVE);
|
|
11
11
|
}
|
|
12
|
-
if (
|
|
13
|
-
!Object.values(enums_1.ServicesTypes).includes(
|
|
12
|
+
if (providerService.type === undefined ||
|
|
13
|
+
!Object.values(enums_1.ServicesTypes).includes(providerService.type)) {
|
|
14
14
|
throw new errors_1.DoctoCarError("Professional service type is required and must be a valid professional service type", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_TYPE);
|
|
15
15
|
}
|
|
16
|
-
const servicePublicConfig = countryServicePublicConfig[
|
|
16
|
+
const servicePublicConfig = countryServicePublicConfig[providerService.type];
|
|
17
17
|
if (servicePublicConfig === undefined) {
|
|
18
18
|
throw new errors_1.DoctoCarError("Professional service public config is not defined for the professional service type", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_TYPE);
|
|
19
19
|
}
|
|
20
|
-
if (
|
|
21
|
-
for (const pricingAndDuration of Object.values(
|
|
20
|
+
if (providerService.pricingAndDurationByVehicleType !== undefined) {
|
|
21
|
+
for (const pricingAndDuration of Object.values(providerService.pricingAndDurationByVehicleType)) {
|
|
22
22
|
if (!(0, isValidServicePricingAndDurationForVehicle_1.isValidServicePricingAndDurationForVehicle)({
|
|
23
23
|
servicePublicConfig: servicePublicConfig,
|
|
24
24
|
servicePricingAndDurationForVehicle: pricingAndDuration,
|
|
@@ -29,13 +29,13 @@ async function isValidProfessionalService({ professionalService, countryServiceP
|
|
|
29
29
|
}
|
|
30
30
|
const parentsServices = servicePublicConfig.parentsServices;
|
|
31
31
|
if (parentsServices !== undefined && parentsServices.length > 0) {
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
throw new errors_1.DoctoCarError("
|
|
32
|
+
if (providerService.parentsServices === undefined ||
|
|
33
|
+
providerService.parentsServices.length !== parentsServices.length) {
|
|
34
|
+
throw new errors_1.DoctoCarError("Service provider service parents services are required and must match the service provider service type", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_PARENTS_SERVICES);
|
|
35
35
|
}
|
|
36
36
|
for (const parentService of parentsServices) {
|
|
37
|
-
if (!
|
|
38
|
-
throw new errors_1.DoctoCarError("
|
|
37
|
+
if (!providerService.parentsServices?.includes(parentService)) {
|
|
38
|
+
throw new errors_1.DoctoCarError("Service provider service parents services are required and must match the service provider service type", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_PARENTS_SERVICES);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isValidProviderService = isValidProviderService;
|
|
4
|
+
const errors_1 = require("../../../../../errors");
|
|
5
|
+
const enums_1 = require("../../../enums");
|
|
6
|
+
const isValidServicePricingAndDurationForVehicle_1 = require("./isValidServicePricingAndDurationForVehicle");
|
|
7
|
+
async function isValidProviderService({ providerService, countryServicePublicConfig, }) {
|
|
8
|
+
if (providerService.isActive === undefined ||
|
|
9
|
+
typeof providerService.isActive !== "boolean") {
|
|
10
|
+
throw new errors_1.DoctoCarError("Provider service isActive must be a boolean", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_IS_ACTIVE);
|
|
11
|
+
}
|
|
12
|
+
if (providerService.type === undefined ||
|
|
13
|
+
!Object.values(enums_1.ServicesTypes).includes(providerService.type)) {
|
|
14
|
+
throw new errors_1.DoctoCarError("Provider service type is required and must be a valid ServicesTypes value", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_TYPE);
|
|
15
|
+
}
|
|
16
|
+
const servicePublicConfig = countryServicePublicConfig[providerService.type];
|
|
17
|
+
if (servicePublicConfig === undefined) {
|
|
18
|
+
throw new errors_1.DoctoCarError("Country services public config has no entry for this provider service type", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_TYPE);
|
|
19
|
+
}
|
|
20
|
+
if (providerService.pricingAndDurationByVehicleType !== undefined) {
|
|
21
|
+
for (const pricingAndDuration of Object.values(providerService.pricingAndDurationByVehicleType)) {
|
|
22
|
+
if (!(0, isValidServicePricingAndDurationForVehicle_1.isValidServicePricingAndDurationForVehicle)({
|
|
23
|
+
servicePublicConfig: servicePublicConfig,
|
|
24
|
+
servicePricingAndDurationForVehicle: pricingAndDuration,
|
|
25
|
+
})) {
|
|
26
|
+
throw new errors_1.DoctoCarError("Pricing and duration for this vehicle type is not valid for this provider service", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_VEHICLE_TYPE_PRICING_AND_DURATION);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const parentsServices = servicePublicConfig.parentsServices;
|
|
31
|
+
if (parentsServices !== undefined && parentsServices.length > 0) {
|
|
32
|
+
if (providerService.parentsServices === undefined ||
|
|
33
|
+
providerService.parentsServices.length !== parentsServices.length) {
|
|
34
|
+
throw new errors_1.DoctoCarError("Provider service parent services must match the service type configuration", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_PARENTS_SERVICES);
|
|
35
|
+
}
|
|
36
|
+
for (const parentService of parentsServices) {
|
|
37
|
+
if (!providerService.parentsServices?.includes(parentService)) {
|
|
38
|
+
throw new errors_1.DoctoCarError("Provider service parent services must match the service type configuration", errors_1.DoctoCarValidationErrorCodes.INVALID_SERVICE_PARENTS_SERVICES);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -17,13 +17,13 @@ function isValidServicePricingAndDurationForVehicle({ servicePricingAndDurationF
|
|
|
17
17
|
servicePricingAndDurationForVehicle.pricePreTaxInCents <=
|
|
18
18
|
servicePublicConfigForVehicle.maximumPriceInCents &&
|
|
19
19
|
servicePricingAndDurationForVehicle.pricePreTaxInCents %
|
|
20
|
-
constants_1.
|
|
20
|
+
constants_1.PROVIDER_SERVICE_MINIMUM_PRICE_INCREMENT_IN_CENTS ===
|
|
21
21
|
0 &&
|
|
22
22
|
Object.values(enums_1.SupportedIsoCurrency).includes(servicePricingAndDurationForVehicle.currency) &&
|
|
23
23
|
typeof servicePricingAndDurationForVehicle.durationInMinutes === "number" &&
|
|
24
24
|
servicePricingAndDurationForVehicle.durationInMinutes ==
|
|
25
25
|
servicePublicConfigForVehicle.durationInMinutes &&
|
|
26
26
|
servicePricingAndDurationForVehicle.durationInMinutes %
|
|
27
|
-
constants_1.
|
|
27
|
+
constants_1.PROVIDER_SERVICE_MINIMUM_DURATION_INCREMENT_IN_MINUTES ===
|
|
28
28
|
0);
|
|
29
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ServicesTypes } from "../../../../enums";
|
|
2
|
-
import type { CountryServicesPublicConfig,
|
|
2
|
+
import type { CountryServicesPublicConfig, ProviderService } from "../../../../types";
|
|
3
3
|
export type IsValidProfessionalServiceParams = {
|
|
4
|
-
|
|
4
|
+
providerService: ProviderService<ServicesTypes>;
|
|
5
5
|
countryServicePublicConfig: CountryServicesPublicConfig;
|
|
6
6
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ServicesTypes } from "../../../../enums";
|
|
2
|
+
import type { CountryServicesPublicConfig, ProviderService } from "../../../../types";
|
|
3
|
+
export type IsValidProviderServiceParams = {
|
|
4
|
+
providerService: ProviderService<ServicesTypes>;
|
|
5
|
+
countryServicePublicConfig: CountryServicesPublicConfig;
|
|
6
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./IsValidServicePricingAndDurationForVehicleParams.type";
|
|
2
|
-
export * from "./
|
|
2
|
+
export * from "./IsValidProviderServiceParams.type";
|
|
@@ -15,4 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./IsValidServicePricingAndDurationForVehicleParams.type"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./IsValidProviderServiceParams.type"), exports);
|
|
@@ -15,7 +15,7 @@ jest.mock("../../services", () => {
|
|
|
15
15
|
describe("buildOrderServicePreTaxLinesAndServicesDetails", () => {
|
|
16
16
|
let getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock;
|
|
17
17
|
let getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowReturn;
|
|
18
|
-
let
|
|
18
|
+
let serviceProviderUserPublicDocument;
|
|
19
19
|
let serviceTypes;
|
|
20
20
|
let vehicleType;
|
|
21
21
|
let countryServicesPublicConfig;
|
|
@@ -30,8 +30,8 @@ describe("buildOrderServicePreTaxLinesAndServicesDetails", () => {
|
|
|
30
30
|
type: enums_2.VehicleTypes.MOTORCYCLE,
|
|
31
31
|
};
|
|
32
32
|
getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock.mockReturnValue(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowReturn);
|
|
33
|
-
|
|
34
|
-
(0, stubs_1.
|
|
33
|
+
serviceProviderUserPublicDocument =
|
|
34
|
+
(0, stubs_1.firestoreServiceProviderUserPublicDocumentStub)();
|
|
35
35
|
serviceTypes = [
|
|
36
36
|
enums_2.ServicesTypes.EXTERIOR_CLEANING,
|
|
37
37
|
enums_2.ServicesTypes.INTERIOR_CLEANING,
|
|
@@ -70,13 +70,13 @@ describe("buildOrderServicePreTaxLinesAndServicesDetails", () => {
|
|
|
70
70
|
getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock.mockReturnValue(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowReturn);
|
|
71
71
|
const result = (0, buildOrderServicePreTaxLinesAndServicesDetails_1.buildOrderServicePreTaxLinesAndServicesDetails)({
|
|
72
72
|
serviceTypes,
|
|
73
|
-
|
|
73
|
+
serviceProviderUserPublicDocument,
|
|
74
74
|
vehicleType,
|
|
75
75
|
countryServicesPublicConfig,
|
|
76
76
|
});
|
|
77
77
|
expect(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock).toHaveBeenCalledTimes(1);
|
|
78
78
|
expect(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock).toHaveBeenCalledWith({
|
|
79
|
-
|
|
79
|
+
serviceProviderUserPublicDocument,
|
|
80
80
|
serviceType: serviceTypes[0],
|
|
81
81
|
vehicleType,
|
|
82
82
|
});
|
|
@@ -104,23 +104,23 @@ describe("buildOrderServicePreTaxLinesAndServicesDetails", () => {
|
|
|
104
104
|
it("should map multiple service types and subservices correctly", () => {
|
|
105
105
|
const result = (0, buildOrderServicePreTaxLinesAndServicesDetails_1.buildOrderServicePreTaxLinesAndServicesDetails)({
|
|
106
106
|
serviceTypes,
|
|
107
|
-
|
|
107
|
+
serviceProviderUserPublicDocument,
|
|
108
108
|
vehicleType,
|
|
109
109
|
countryServicesPublicConfig,
|
|
110
110
|
});
|
|
111
111
|
expect(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock).toHaveBeenCalledTimes(3);
|
|
112
112
|
expect(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock).toHaveBeenNthCalledWith(1, {
|
|
113
|
-
|
|
113
|
+
serviceProviderUserPublicDocument,
|
|
114
114
|
serviceType: enums_2.ServicesTypes.EXTERIOR_CLEANING,
|
|
115
115
|
vehicleType,
|
|
116
116
|
});
|
|
117
117
|
expect(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock).toHaveBeenNthCalledWith(2, {
|
|
118
|
-
|
|
118
|
+
serviceProviderUserPublicDocument,
|
|
119
119
|
serviceType: enums_2.ServicesTypes.INTERIOR_CLEANING,
|
|
120
120
|
vehicleType,
|
|
121
121
|
});
|
|
122
122
|
expect(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock).toHaveBeenNthCalledWith(3, {
|
|
123
|
-
|
|
123
|
+
serviceProviderUserPublicDocument,
|
|
124
124
|
serviceType: enums_2.ServicesTypes.ANIMAL_HAIR_TREATMENT,
|
|
125
125
|
vehicleType,
|
|
126
126
|
});
|
|
@@ -193,13 +193,13 @@ describe("buildOrderServicePreTaxLinesAndServicesDetails", () => {
|
|
|
193
193
|
getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock.mockReturnValue(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowReturn);
|
|
194
194
|
const result = (0, buildOrderServicePreTaxLinesAndServicesDetails_1.buildOrderServicePreTaxLinesAndServicesDetails)({
|
|
195
195
|
serviceTypes,
|
|
196
|
-
|
|
196
|
+
serviceProviderUserPublicDocument,
|
|
197
197
|
vehicleType,
|
|
198
198
|
countryServicesPublicConfig,
|
|
199
199
|
});
|
|
200
200
|
expect(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock).toHaveBeenCalledTimes(1);
|
|
201
201
|
expect(getServiceProviderActiveServicePricingAndDurationForVehicleOrThrowMock).toHaveBeenCalledWith({
|
|
202
|
-
|
|
202
|
+
serviceProviderUserPublicDocument,
|
|
203
203
|
serviceType: serviceTypes[0],
|
|
204
204
|
vehicleType,
|
|
205
205
|
});
|
|
@@ -231,7 +231,7 @@ describe("buildOrderServicePreTaxLinesAndServicesDetails", () => {
|
|
|
231
231
|
});
|
|
232
232
|
expect(() => (0, buildOrderServicePreTaxLinesAndServicesDetails_1.buildOrderServicePreTaxLinesAndServicesDetails)({
|
|
233
233
|
serviceTypes,
|
|
234
|
-
|
|
234
|
+
serviceProviderUserPublicDocument,
|
|
235
235
|
vehicleType,
|
|
236
236
|
countryServicesPublicConfig,
|
|
237
237
|
})).toThrow("Service pricing not found");
|
|
@@ -250,7 +250,7 @@ describe("buildOrderServicePreTaxLinesAndServicesDetails", () => {
|
|
|
250
250
|
});
|
|
251
251
|
expect(() => (0, buildOrderServicePreTaxLinesAndServicesDetails_1.buildOrderServicePreTaxLinesAndServicesDetails)({
|
|
252
252
|
serviceTypes,
|
|
253
|
-
|
|
253
|
+
serviceProviderUserPublicDocument,
|
|
254
254
|
vehicleType,
|
|
255
255
|
countryServicesPublicConfig,
|
|
256
256
|
})).toThrow(`Service type ${enums_2.ServicesTypes.ANIMAL_HAIR_TREATMENT} is not available in the country configuration.`);
|
package/dist/firebase/firestore/utils/order/buildOrderServicePreTaxLinesAndServicesDetails.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { BuildOrderServicePreTaxLinesAndServicesDetailsReturn, BuildOrderServicePreTaxLinesAndServicesDetailsProps } from "./types";
|
|
2
|
-
export declare function buildOrderServicePreTaxLinesAndServicesDetails({ countryServicesPublicConfig, serviceTypes,
|
|
2
|
+
export declare function buildOrderServicePreTaxLinesAndServicesDetails({ countryServicesPublicConfig, serviceTypes, serviceProviderUserPublicDocument, vehicleType, }: BuildOrderServicePreTaxLinesAndServicesDetailsProps): BuildOrderServicePreTaxLinesAndServicesDetailsReturn;
|
package/dist/firebase/firestore/utils/order/buildOrderServicePreTaxLinesAndServicesDetails.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.buildOrderServicePreTaxLinesAndServicesDetails = buildOrderServicePreTax
|
|
|
4
4
|
const pricing_1 = require("../../../../pricing");
|
|
5
5
|
const enums_1 = require("../../enums");
|
|
6
6
|
const services_1 = require("../services");
|
|
7
|
-
function buildOrderServicePreTaxLinesAndServicesDetails({ countryServicesPublicConfig, serviceTypes,
|
|
7
|
+
function buildOrderServicePreTaxLinesAndServicesDetails({ countryServicesPublicConfig, serviceTypes, serviceProviderUserPublicDocument, vehicleType, }) {
|
|
8
8
|
const servicesPreTaxLines = [];
|
|
9
9
|
const orderServicesDetails = [];
|
|
10
10
|
serviceTypes.forEach((serviceType, index) => {
|
|
@@ -12,7 +12,7 @@ function buildOrderServicePreTaxLinesAndServicesDetails({ countryServicesPublicC
|
|
|
12
12
|
throw new Error(`Service type ${serviceType} is not available in the country configuration.`);
|
|
13
13
|
}
|
|
14
14
|
const pricingAndDurationForVehicle = (0, services_1.getServiceProviderActiveServicePricingAndDurationForVehicleOrThrow)({
|
|
15
|
-
|
|
15
|
+
serviceProviderUserPublicDocument,
|
|
16
16
|
serviceType,
|
|
17
17
|
vehicleType,
|
|
18
18
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ServicesTypes, VehicleTypes } from "../../../enums";
|
|
2
|
-
import type { CountryServicesPublicConfig,
|
|
2
|
+
import type { CountryServicesPublicConfig, FirestoreServiceProviderUserPublicDocument } from "../../../types";
|
|
3
3
|
export type BuildOrderServicePreTaxLinesAndServicesDetailsProps = {
|
|
4
4
|
countryServicesPublicConfig: CountryServicesPublicConfig;
|
|
5
5
|
serviceTypes: ServicesTypes[];
|
|
6
|
-
|
|
6
|
+
serviceProviderUserPublicDocument: FirestoreServiceProviderUserPublicDocument;
|
|
7
7
|
vehicleType: VehicleTypes;
|
|
8
8
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/firebase/firestore/utils/reviews/__tests__/getAverageRatingFromReviewAggregates.test.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getAverageRatingFromReviewAggregates_1 = require("../getAverageRatingFromReviewAggregates");
|
|
4
|
+
describe("getAverageRatingFromReviewAggregates", () => {
|
|
5
|
+
const cases = [
|
|
6
|
+
{
|
|
7
|
+
name: "normal positive numbers",
|
|
8
|
+
input: { reviewCount: 5, ratingSum: 20 },
|
|
9
|
+
expected: 4,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "zero reviews",
|
|
13
|
+
input: { reviewCount: 0, ratingSum: 0 },
|
|
14
|
+
expected: 0,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "positive count, zero sum",
|
|
18
|
+
input: { reviewCount: 3, ratingSum: 0 },
|
|
19
|
+
expected: 0,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "negative count",
|
|
23
|
+
input: { reviewCount: -1, ratingSum: 10 },
|
|
24
|
+
expected: 0,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: "negative sum",
|
|
28
|
+
input: { reviewCount: 4, ratingSum: -5 },
|
|
29
|
+
expected: 0,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "both negative",
|
|
33
|
+
input: { reviewCount: -3, ratingSum: -5 },
|
|
34
|
+
expected: 0,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "string count coerced",
|
|
38
|
+
input: { reviewCount: "3", ratingSum: 5 },
|
|
39
|
+
expected: 1.67,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: "string sum coerced",
|
|
43
|
+
input: { reviewCount: 3, ratingSum: "5" },
|
|
44
|
+
expected: 1.67,
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "string both coerced",
|
|
48
|
+
input: {
|
|
49
|
+
reviewCount: "3",
|
|
50
|
+
ratingSum: "5",
|
|
51
|
+
},
|
|
52
|
+
expected: 1.67,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "fractional inputs",
|
|
56
|
+
input: {
|
|
57
|
+
reviewCount: 2.5,
|
|
58
|
+
ratingSum: 5.5,
|
|
59
|
+
},
|
|
60
|
+
expected: 2.2,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "sum smaller than count",
|
|
64
|
+
input: { reviewCount: 10, ratingSum: 5 },
|
|
65
|
+
expected: 0.5,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "very large numbers",
|
|
69
|
+
input: { reviewCount: 1e9, ratingSum: 5e9 },
|
|
70
|
+
expected: 5,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "undefined fields",
|
|
74
|
+
input: {},
|
|
75
|
+
expected: 0,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "null inputs",
|
|
79
|
+
input: {
|
|
80
|
+
reviewCount: null,
|
|
81
|
+
ratingSum: null,
|
|
82
|
+
},
|
|
83
|
+
expected: 0,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "NaN inputs",
|
|
87
|
+
input: { reviewCount: NaN, ratingSum: NaN },
|
|
88
|
+
expected: 0,
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
describe.each(cases)("$name", ({ input, expected }) => {
|
|
92
|
+
it(`returns ${expected}`, () => {
|
|
93
|
+
const result = (0, getAverageRatingFromReviewAggregates_1.getAverageRatingFromReviewAggregates)(input);
|
|
94
|
+
expect(result).toBeCloseTo(expected, 2);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAverageRatingFromReviewAggregates = getAverageRatingFromReviewAggregates;
|
|
4
|
+
function getAverageRatingFromReviewAggregates(args) {
|
|
5
|
+
const count = Number(args.reviewCount);
|
|
6
|
+
const sum = Number(args.ratingSum);
|
|
7
|
+
let averageRating = 0;
|
|
8
|
+
if (count > 0 && sum > 0) {
|
|
9
|
+
averageRating = sum / count;
|
|
10
|
+
averageRating = Math.round(averageRating * 100) / 100;
|
|
11
|
+
}
|
|
12
|
+
return averageRating;
|
|
13
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./getAverageRatingFromReviewAggregates
|
|
1
|
+
export * from "./getAverageRatingFromReviewAggregates";
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./getAverageRatingFromReviewAggregates
|
|
17
|
+
__exportStar(require("./getAverageRatingFromReviewAggregates"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
|
+
const enums_1 = require("../../../enums");
|
|
5
|
+
const stubs_1 = require("../../stubs");
|
|
6
|
+
const computeTotalServiceProviderServiceDurationInMinutesForVehicleType_1 = require("../computeTotalServiceProviderServiceDurationInMinutesForVehicleType");
|
|
7
|
+
describe("computeTotalServiceProviderServiceDurationInMinutesForVehicleType", () => {
|
|
8
|
+
let serviceProviderUserPublicDocument;
|
|
9
|
+
beforeEach(() => { });
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
jest.clearAllMocks();
|
|
12
|
+
});
|
|
13
|
+
it("Should return the sum of services durations", () => {
|
|
14
|
+
serviceProviderUserPublicDocument =
|
|
15
|
+
(0, stubs_1.firestoreServiceProviderUserPublicDocumentStub)({
|
|
16
|
+
services: {
|
|
17
|
+
[enums_1.ServicesTypes.ANIMAL_HAIR_TREATMENT]: (0, stubs_1.providerServiceStub)({
|
|
18
|
+
type: enums_1.ServicesTypes.ANIMAL_HAIR_TREATMENT,
|
|
19
|
+
pricingAndDurationByVehicleType: {
|
|
20
|
+
[enums_1.VehicleTypes.CITY_CAR]: (0, stubs_1.pricingAndDurationForVehicleStub)({
|
|
21
|
+
durationInMinutes: 30,
|
|
22
|
+
}),
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
[enums_1.ServicesTypes.CARPET_SHAMPOO]: (0, stubs_1.providerServiceStub)({
|
|
26
|
+
type: enums_1.ServicesTypes.CARPET_SHAMPOO,
|
|
27
|
+
pricingAndDurationByVehicleType: {
|
|
28
|
+
[enums_1.VehicleTypes.CITY_CAR]: (0, stubs_1.pricingAndDurationForVehicleStub)({
|
|
29
|
+
durationInMinutes: 30,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
[enums_1.ServicesTypes.INTERIOR_CLEANING]: (0, stubs_1.providerServiceStub)({
|
|
34
|
+
type: enums_1.ServicesTypes.INTERIOR_CLEANING,
|
|
35
|
+
pricingAndDurationByVehicleType: {
|
|
36
|
+
[enums_1.VehicleTypes.CITY_CAR]: (0, stubs_1.pricingAndDurationForVehicleStub)({
|
|
37
|
+
durationInMinutes: 60,
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
const result = (0, computeTotalServiceProviderServiceDurationInMinutesForVehicleType_1.computeTotalServiceProviderServiceDurationInMinutesForVehicleType)({
|
|
44
|
+
servicesTypes: [
|
|
45
|
+
enums_1.ServicesTypes.INTERIOR_CLEANING,
|
|
46
|
+
enums_1.ServicesTypes.ANIMAL_HAIR_TREATMENT,
|
|
47
|
+
enums_1.ServicesTypes.CARPET_SHAMPOO,
|
|
48
|
+
],
|
|
49
|
+
vehicleType: enums_1.VehicleTypes.CITY_CAR,
|
|
50
|
+
services: serviceProviderUserPublicDocument.services,
|
|
51
|
+
});
|
|
52
|
+
expect(result).toBe(120);
|
|
53
|
+
});
|
|
54
|
+
it("Should throw if service type is not found in services", () => {
|
|
55
|
+
serviceProviderUserPublicDocument =
|
|
56
|
+
(0, stubs_1.firestoreServiceProviderUserPublicDocumentStub)({
|
|
57
|
+
services: {
|
|
58
|
+
[enums_1.ServicesTypes.EXTERIOR_CLEANING]: (0, stubs_1.providerServiceStub)({
|
|
59
|
+
type: enums_1.ServicesTypes.EXTERIOR_CLEANING,
|
|
60
|
+
pricingAndDurationByVehicleType: {
|
|
61
|
+
[enums_1.VehicleTypes.CITY_CAR]: (0, stubs_1.pricingAndDurationForVehicleStub)({
|
|
62
|
+
durationInMinutes: 30,
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
expect(() => (0, computeTotalServiceProviderServiceDurationInMinutesForVehicleType_1.computeTotalServiceProviderServiceDurationInMinutesForVehicleType)({
|
|
69
|
+
servicesTypes: [enums_1.ServicesTypes.INTERIOR_CLEANING],
|
|
70
|
+
vehicleType: enums_1.VehicleTypes.CITY_CAR,
|
|
71
|
+
services: serviceProviderUserPublicDocument.services,
|
|
72
|
+
})).toThrow(`computeTotalServiceProviderServiceDurationInMinutes: Service type ${enums_1.ServicesTypes.INTERIOR_CLEANING} not found for vehicle type ${enums_1.VehicleTypes.CITY_CAR}`);
|
|
73
|
+
});
|
|
74
|
+
it("Should throw if a service exists but has no pricingAndDuration for the requested vehicle", async () => {
|
|
75
|
+
serviceProviderUserPublicDocument =
|
|
76
|
+
(0, stubs_1.firestoreServiceProviderUserPublicDocumentStub)({
|
|
77
|
+
services: {
|
|
78
|
+
[enums_1.ServicesTypes.EXTERIOR_CLEANING]: (0, stubs_1.providerServiceStub)({
|
|
79
|
+
type: enums_1.ServicesTypes.EXTERIOR_CLEANING,
|
|
80
|
+
pricingAndDurationByVehicleType: {
|
|
81
|
+
[enums_1.VehicleTypes.SEDAN]: (0, stubs_1.pricingAndDurationForVehicleStub)({
|
|
82
|
+
durationInMinutes: 45,
|
|
83
|
+
}),
|
|
84
|
+
},
|
|
85
|
+
}),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
await expect(() => (0, computeTotalServiceProviderServiceDurationInMinutesForVehicleType_1.computeTotalServiceProviderServiceDurationInMinutesForVehicleType)({
|
|
89
|
+
servicesTypes: [enums_1.ServicesTypes.EXTERIOR_CLEANING],
|
|
90
|
+
vehicleType: enums_1.VehicleTypes.CITY_CAR,
|
|
91
|
+
services: serviceProviderUserPublicDocument.services,
|
|
92
|
+
})).toThrow(`computeTotalServiceProviderServiceDurationInMinutes: Service type ${enums_1.ServicesTypes.EXTERIOR_CLEANING} not found for vehicle type ${enums_1.VehicleTypes.CITY_CAR}`);
|
|
93
|
+
});
|
|
94
|
+
it("Should throw if services is undefined", () => {
|
|
95
|
+
expect(() => (0, computeTotalServiceProviderServiceDurationInMinutesForVehicleType_1.computeTotalServiceProviderServiceDurationInMinutesForVehicleType)({
|
|
96
|
+
servicesTypes: [enums_1.ServicesTypes.EXTERIOR_CLEANING],
|
|
97
|
+
vehicleType: enums_1.VehicleTypes.CITY_CAR,
|
|
98
|
+
services: undefined,
|
|
99
|
+
})).toThrow(`computeTotalServiceProviderServiceDurationInMinutes: Service type ${enums_1.ServicesTypes.EXTERIOR_CLEANING} not found for vehicle type ${enums_1.VehicleTypes.CITY_CAR}`);
|
|
100
|
+
});
|
|
101
|
+
});
|
package/dist/firebase/firestore/utils/services/__tests__/createServiceVehicleComboKey.test.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const enums_1 = require("../../../enums");
|
|
4
4
|
const createServiceVehicleComboKey_1 = require("../createServiceVehicleComboKey");
|
|
5
5
|
describe("createServiceVehicleComboKey", () => {
|
|
6
|
-
it("should return a string with the
|
|
7
|
-
const
|
|
6
|
+
it("should return a string with the serviceType and vehicleType separated by an underscore", () => {
|
|
7
|
+
const serviceType = enums_1.ServicesTypes.INTERIOR_CLEANING;
|
|
8
8
|
const vehicleType = enums_1.VehicleTypes.CITY_CAR;
|
|
9
|
-
const result = (0, createServiceVehicleComboKey_1.createServiceVehicleComboKey)(
|
|
10
|
-
expect(result).toBe(`${
|
|
9
|
+
const result = (0, createServiceVehicleComboKey_1.createServiceVehicleComboKey)(serviceType, vehicleType);
|
|
10
|
+
expect(result).toBe(`${serviceType}_${vehicleType}`);
|
|
11
11
|
});
|
|
12
12
|
});
|