@shophost/rest-api 2.0.65 → 2.0.68
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/package.json +2 -2
- package/scripts/shophost-rest-api.mjs +0 -1
- package/src/container.d.ts +2 -2
- package/src/container.js +1 -1
- package/src/core/lib/prisma.d.ts +24 -24
- package/src/core/notifications/email.service.d.ts +1 -1
- package/src/core/notifications/email.service.js +1 -1
- package/src/features/cart/cart.service.js +1 -1
- package/src/features/customer/customer.route.d.ts +4 -4
- package/src/features/customer/customer.schema.d.ts +4 -4
- package/src/features/customer/customer.service.d.ts +1 -1
- package/src/features/integration/integration.service.d.ts +1 -1
- package/src/features/integration/integration.service.js +1 -1
- package/src/features/order/order-fulfillment.service.js +1 -1
- package/src/features/order/order.handler.js +1 -1
- package/src/features/order/order.route.d.ts +139 -21
- package/src/features/order/order.route.js +1 -1
- package/src/features/order/order.schema.d.ts +4 -4
- package/src/features/order/order.service.d.ts +13 -7
- package/src/features/order/order.service.js +1 -1
- package/src/features/order/recipient.schema.d.ts +1 -1
- package/src/features/organization/legal-entity.schema.d.ts +1 -1
- package/src/features/organization/organization-configuration.schema.d.ts +1 -1
- package/src/features/organization/organization.route.d.ts +5 -5
- package/src/features/organization/organization.schema.d.ts +2 -2
- package/src/features/organization/organization.service.d.ts +4 -4
- package/src/features/payment/payment-webhook.service.d.ts +1 -3
- package/src/features/payment/payment-webhook.service.js +1 -1
- package/src/features/payment/payment.schema.d.ts +1 -1
- package/src/features/payment/payment.schema.js +1 -1
- package/src/features/payment/payment.service.d.ts +1 -0
- package/src/features/payment/stripe.service.d.ts +4 -1
- package/src/features/payment/stripe.service.js +1 -1
- package/src/features/reservation/emails/reservation-cancellation.email.js +1 -1
- package/src/features/reservation/emails/reservation-confirmation.email.js +1 -1
- package/src/features/reservation/emails/reservation-notification.email.js +1 -1
- package/src/features/shipping/shipping.route.d.ts +4 -4
- package/src/features/shipping/shipping.service.d.ts +3 -3
- package/src/features/webhook/webhook.handler.js +1 -1
- package/src/features/webhook/webhook.route.d.ts +2 -2
- package/src/features/webhook/webhook.route.js +1 -1
- package/src/schemas/address.schema.d.ts +3 -3
- package/src/schemas/address.schema.js +1 -1
- package/scripts/minify-dist.mjs +0 -45
- package/src/bootstrap.js.map +0 -1
- package/src/container.js.map +0 -1
- package/src/core/auth/auth.schema.js.map +0 -1
- package/src/core/auth/auth.util.js.map +0 -1
- package/src/core/auth/better-auth.lib.js.map +0 -1
- package/src/core/auth/generate-password-hash.util.js.map +0 -1
- package/src/core/auth/headers.schema.js.map +0 -1
- package/src/core/auth/user.schema.js.map +0 -1
- package/src/core/db/__generated__/client/browser.js.map +0 -1
- package/src/core/db/__generated__/client/client.js.map +0 -1
- package/src/core/db/__generated__/client/commonInputTypes.js.map +0 -1
- package/src/core/db/__generated__/client/enums.js.map +0 -1
- package/src/core/db/__generated__/client/internal/class.js.map +0 -1
- package/src/core/db/__generated__/client/internal/prismaNamespace.js.map +0 -1
- package/src/core/db/__generated__/client/internal/prismaNamespaceBrowser.js.map +0 -1
- package/src/core/db/__generated__/client/models/Account.js.map +0 -1
- package/src/core/db/__generated__/client/models/Address.js.map +0 -1
- package/src/core/db/__generated__/client/models/Campaign.js.map +0 -1
- package/src/core/db/__generated__/client/models/ClosingTimes.js.map +0 -1
- package/src/core/db/__generated__/client/models/File.js.map +0 -1
- package/src/core/db/__generated__/client/models/Integration.js.map +0 -1
- package/src/core/db/__generated__/client/models/Invitation.js.map +0 -1
- package/src/core/db/__generated__/client/models/LegalEntity.js.map +0 -1
- package/src/core/db/__generated__/client/models/Manufacturer.js.map +0 -1
- package/src/core/db/__generated__/client/models/ManufacturerTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/Member.js.map +0 -1
- package/src/core/db/__generated__/client/models/Modifier.js.map +0 -1
- package/src/core/db/__generated__/client/models/ModifierGroup.js.map +0 -1
- package/src/core/db/__generated__/client/models/ModifierGroupTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/OpeningTimes.js.map +0 -1
- package/src/core/db/__generated__/client/models/Order.js.map +0 -1
- package/src/core/db/__generated__/client/models/OrderItem.js.map +0 -1
- package/src/core/db/__generated__/client/models/OrderItemTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/Organization.js.map +0 -1
- package/src/core/db/__generated__/client/models/OrganizationConfiguration.js.map +0 -1
- package/src/core/db/__generated__/client/models/Payment.js.map +0 -1
- package/src/core/db/__generated__/client/models/PaymentSession.js.map +0 -1
- package/src/core/db/__generated__/client/models/Product.js.map +0 -1
- package/src/core/db/__generated__/client/models/ProductCategory.js.map +0 -1
- package/src/core/db/__generated__/client/models/ProductCategoryTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/ProductSnapshot.js.map +0 -1
- package/src/core/db/__generated__/client/models/ProductTranslation.js.map +0 -1
- package/src/core/db/__generated__/client/models/Reservation.js.map +0 -1
- package/src/core/db/__generated__/client/models/Session.js.map +0 -1
- package/src/core/db/__generated__/client/models/ShippingMethod.js.map +0 -1
- package/src/core/db/__generated__/client/models/ShippingZone.js.map +0 -1
- package/src/core/db/__generated__/client/models/User.js.map +0 -1
- package/src/core/db/__generated__/client/models/Verification.js.map +0 -1
- package/src/core/db/__generated__/client/models.js.map +0 -1
- package/src/core/db/index.js.map +0 -1
- package/src/core/email/components.js.map +0 -1
- package/src/core/exceptions/http-exception.js.map +0 -1
- package/src/core/hono/hono.js.map +0 -1
- package/src/core/lib/prisma.js.map +0 -1
- package/src/core/logging/pino.js.map +0 -1
- package/src/core/notifications/email.service.js.map +0 -1
- package/src/core/openapi/openapi.lib.js.map +0 -1
- package/src/core/types/google-maps.types.js.map +0 -1
- package/src/core/utils/currency.util.js.map +0 -1
- package/src/core/utils/env.util.js.map +0 -1
- package/src/core/utils/object.util.js.map +0 -1
- package/src/core/utils/translations.util.js.map +0 -1
- package/src/core/utils/zod.util.js.map +0 -1
- package/src/db.js.map +0 -1
- package/src/features/access/access.handler.js.map +0 -1
- package/src/features/access/access.route.js.map +0 -1
- package/src/features/access/access.schema.js.map +0 -1
- package/src/features/access/access.service.js.map +0 -1
- package/src/features/analytics/analytics.handler.js.map +0 -1
- package/src/features/analytics/analytics.route.js.map +0 -1
- package/src/features/analytics/analytics.schema.js.map +0 -1
- package/src/features/analytics/analytics.service.js.map +0 -1
- package/src/features/cart/cart.handler.js.map +0 -1
- package/src/features/cart/cart.route.js.map +0 -1
- package/src/features/cart/cart.schema.js.map +0 -1
- package/src/features/cart/cart.service.js.map +0 -1
- package/src/features/cart/cart.util.js.map +0 -1
- package/src/features/customer/customer.handler.js.map +0 -1
- package/src/features/customer/customer.route.js.map +0 -1
- package/src/features/customer/customer.schema.js.map +0 -1
- package/src/features/customer/customer.service.js.map +0 -1
- package/src/features/file/file.handler.js.map +0 -1
- package/src/features/file/file.route.js.map +0 -1
- package/src/features/file/file.schema.js.map +0 -1
- package/src/features/file/file.service.js.map +0 -1
- package/src/features/health/health.handler.js.map +0 -1
- package/src/features/health/health.route.js.map +0 -1
- package/src/features/index.js.map +0 -1
- package/src/features/integration/integration-config.js.map +0 -1
- package/src/features/integration/integration-registry.js.map +0 -1
- package/src/features/integration/integration.handler.js.map +0 -1
- package/src/features/integration/integration.route.js.map +0 -1
- package/src/features/integration/integration.schema.js.map +0 -1
- package/src/features/integration/integration.service.js.map +0 -1
- package/src/features/inventory/inventory.service.js.map +0 -1
- package/src/features/location/location.handler.js.map +0 -1
- package/src/features/location/location.route.js.map +0 -1
- package/src/features/location/location.schema.js.map +0 -1
- package/src/features/location/location.service.js.map +0 -1
- package/src/features/manufacturer/manufacturer.handler.js.map +0 -1
- package/src/features/manufacturer/manufacturer.route.js.map +0 -1
- package/src/features/manufacturer/manufacturer.schema.js.map +0 -1
- package/src/features/manufacturer/manufacturer.service.js.map +0 -1
- package/src/features/order/emails/order-confirmation.email.js.map +0 -1
- package/src/features/order/emails/order-notification.email.js.map +0 -1
- package/src/features/order/fulfilment.schema.js.map +0 -1
- package/src/features/order/order-fulfillment.service.js.map +0 -1
- package/src/features/order/order.handler.js.map +0 -1
- package/src/features/order/order.route.js.map +0 -1
- package/src/features/order/order.schema.js.map +0 -1
- package/src/features/order/order.service.js.map +0 -1
- package/src/features/order/recipient.schema.js.map +0 -1
- package/src/features/organization/legal-entity.schema.js.map +0 -1
- package/src/features/organization/organization-configuration.schema.js.map +0 -1
- package/src/features/organization/organization.handler.js.map +0 -1
- package/src/features/organization/organization.route.js.map +0 -1
- package/src/features/organization/organization.schema.js.map +0 -1
- package/src/features/organization/organization.service.js.map +0 -1
- package/src/features/payment/payment-webhook.service.js.map +0 -1
- package/src/features/payment/payment.handler.js.map +0 -1
- package/src/features/payment/payment.route.js.map +0 -1
- package/src/features/payment/payment.schema.js.map +0 -1
- package/src/features/payment/payment.service.js.map +0 -1
- package/src/features/payment/stripe.service.js.map +0 -1
- package/src/features/product/product-modifier.schema.js.map +0 -1
- package/src/features/product/product.handler.js.map +0 -1
- package/src/features/product/product.route.js.map +0 -1
- package/src/features/product/product.schema.js.map +0 -1
- package/src/features/product/product.service.js.map +0 -1
- package/src/features/product-category/product-category.handler.js.map +0 -1
- package/src/features/product-category/product-category.route.js.map +0 -1
- package/src/features/product-category/product-category.schema.js.map +0 -1
- package/src/features/product-category/product-category.service.js.map +0 -1
- package/src/features/reservation/emails/reservation-cancellation.email.js.map +0 -1
- package/src/features/reservation/emails/reservation-confirmation.email.js.map +0 -1
- package/src/features/reservation/emails/reservation-notification.email.js.map +0 -1
- package/src/features/reservation/emails/reservation-updated.email.js.map +0 -1
- package/src/features/reservation/reservation.handler.js.map +0 -1
- package/src/features/reservation/reservation.route.js.map +0 -1
- package/src/features/reservation/reservation.schema.js.map +0 -1
- package/src/features/reservation/reservation.service.js.map +0 -1
- package/src/features/shipping/shipping.handler.js.map +0 -1
- package/src/features/shipping/shipping.route.js.map +0 -1
- package/src/features/shipping/shipping.service.js.map +0 -1
- package/src/features/shipping-method/shipping-method.handler.js.map +0 -1
- package/src/features/shipping-method/shipping-method.route.js.map +0 -1
- package/src/features/shipping-method/shipping-method.schema.js.map +0 -1
- package/src/features/shipping-method/shipping-method.service.js.map +0 -1
- package/src/features/shipping-method/shipping-zone.schema.js.map +0 -1
- package/src/features/webhook/webhook.handler.js.map +0 -1
- package/src/features/webhook/webhook.route.js.map +0 -1
- package/src/index.js.map +0 -1
- package/src/integrations/next.js.map +0 -1
- package/src/schemas/address.schema.js.map +0 -1
- package/src/schemas/currency.schema.js.map +0 -1
- package/src/schemas/error.schema.js.map +0 -1
- package/src/schemas/index.js.map +0 -1
- package/src/schemas/locales.schema.js.map +0 -1
- package/src/schemas/number.schema.js.map +0 -1
- package/src/schemas/pagination.schema.js.map +0 -1
- package/src/schemas/params.schema.js.map +0 -1
- package/src/schemas/queries.schema.js.map +0 -1
|
@@ -355,7 +355,7 @@ export declare const orderRoute: {
|
|
|
355
355
|
zipCode: z.ZodOptional<z.ZodString>;
|
|
356
356
|
city: z.ZodString;
|
|
357
357
|
country: z.ZodString;
|
|
358
|
-
placeId: z.ZodString
|
|
358
|
+
placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
359
359
|
deliveryInstructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
360
360
|
}, z.core.$strip>>>;
|
|
361
361
|
fulfilmentMethod: z.ZodEnum<{
|
|
@@ -421,7 +421,7 @@ export declare const orderRoute: {
|
|
|
421
421
|
shipping: z.ZodDefault<z.ZodNumber>;
|
|
422
422
|
subtotal: z.ZodNumber;
|
|
423
423
|
total: z.ZodNumber;
|
|
424
|
-
discount: z.ZodDefault<z.ZodNumber
|
|
424
|
+
discount: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodDefault<z.ZodNumber>>;
|
|
425
425
|
currency: z.ZodEnum<{
|
|
426
426
|
USD: "USD";
|
|
427
427
|
EUR: "EUR";
|
|
@@ -556,13 +556,13 @@ export declare const orderRoute: {
|
|
|
556
556
|
addressLineOne: string;
|
|
557
557
|
city: string;
|
|
558
558
|
country: string;
|
|
559
|
-
placeId: string;
|
|
560
559
|
firstname?: string | null | undefined;
|
|
561
560
|
lastname?: string | null | undefined;
|
|
562
561
|
phone?: string | null | undefined;
|
|
563
562
|
doorNumber?: string | null | undefined;
|
|
564
563
|
addressLineTwo?: string | null | undefined;
|
|
565
564
|
zipCode?: string | undefined;
|
|
565
|
+
placeId?: string | null | undefined;
|
|
566
566
|
deliveryInstructions?: string | null | undefined;
|
|
567
567
|
} | null | undefined;
|
|
568
568
|
}, {
|
|
@@ -663,13 +663,13 @@ export declare const orderRoute: {
|
|
|
663
663
|
addressLineOne: string;
|
|
664
664
|
city: string;
|
|
665
665
|
country: string;
|
|
666
|
-
placeId: string;
|
|
667
666
|
firstname?: string | null | undefined;
|
|
668
667
|
lastname?: string | null | undefined;
|
|
669
668
|
phone?: string | null | undefined;
|
|
670
669
|
doorNumber?: string | null | undefined;
|
|
671
670
|
addressLineTwo?: string | null | undefined;
|
|
672
671
|
zipCode?: string | undefined;
|
|
672
|
+
placeId?: string | null | undefined;
|
|
673
673
|
deliveryInstructions?: string | null | undefined;
|
|
674
674
|
} | null | undefined;
|
|
675
675
|
}>>>;
|
|
@@ -1070,7 +1070,7 @@ export declare const orderRoute: {
|
|
|
1070
1070
|
zipCode: z.ZodOptional<z.ZodString>;
|
|
1071
1071
|
city: z.ZodString;
|
|
1072
1072
|
country: z.ZodString;
|
|
1073
|
-
placeId: z.ZodString
|
|
1073
|
+
placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1074
1074
|
deliveryInstructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1075
1075
|
}, z.core.$strip>>>;
|
|
1076
1076
|
fulfilmentMethod: z.ZodEnum<{
|
|
@@ -1136,7 +1136,7 @@ export declare const orderRoute: {
|
|
|
1136
1136
|
shipping: z.ZodDefault<z.ZodNumber>;
|
|
1137
1137
|
subtotal: z.ZodNumber;
|
|
1138
1138
|
total: z.ZodNumber;
|
|
1139
|
-
discount: z.ZodDefault<z.ZodNumber
|
|
1139
|
+
discount: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodDefault<z.ZodNumber>>;
|
|
1140
1140
|
currency: z.ZodEnum<{
|
|
1141
1141
|
USD: "USD";
|
|
1142
1142
|
EUR: "EUR";
|
|
@@ -1271,13 +1271,13 @@ export declare const orderRoute: {
|
|
|
1271
1271
|
addressLineOne: string;
|
|
1272
1272
|
city: string;
|
|
1273
1273
|
country: string;
|
|
1274
|
-
placeId: string;
|
|
1275
1274
|
firstname?: string | null | undefined;
|
|
1276
1275
|
lastname?: string | null | undefined;
|
|
1277
1276
|
phone?: string | null | undefined;
|
|
1278
1277
|
doorNumber?: string | null | undefined;
|
|
1279
1278
|
addressLineTwo?: string | null | undefined;
|
|
1280
1279
|
zipCode?: string | undefined;
|
|
1280
|
+
placeId?: string | null | undefined;
|
|
1281
1281
|
deliveryInstructions?: string | null | undefined;
|
|
1282
1282
|
} | null | undefined;
|
|
1283
1283
|
}, {
|
|
@@ -1378,13 +1378,13 @@ export declare const orderRoute: {
|
|
|
1378
1378
|
addressLineOne: string;
|
|
1379
1379
|
city: string;
|
|
1380
1380
|
country: string;
|
|
1381
|
-
placeId: string;
|
|
1382
1381
|
firstname?: string | null | undefined;
|
|
1383
1382
|
lastname?: string | null | undefined;
|
|
1384
1383
|
phone?: string | null | undefined;
|
|
1385
1384
|
doorNumber?: string | null | undefined;
|
|
1386
1385
|
addressLineTwo?: string | null | undefined;
|
|
1387
1386
|
zipCode?: string | undefined;
|
|
1387
|
+
placeId?: string | null | undefined;
|
|
1388
1388
|
deliveryInstructions?: string | null | undefined;
|
|
1389
1389
|
} | null | undefined;
|
|
1390
1390
|
}>>>;
|
|
@@ -1485,7 +1485,125 @@ export declare const orderRoute: {
|
|
|
1485
1485
|
params: z.ZodObject<{
|
|
1486
1486
|
organizationId: z.ZodString;
|
|
1487
1487
|
}, z.core.$strip>;
|
|
1488
|
-
} &
|
|
1488
|
+
} & {
|
|
1489
|
+
query: z.ZodObject<{
|
|
1490
|
+
locale: z.ZodOptional<z.ZodEnum<{
|
|
1491
|
+
hr: "hr";
|
|
1492
|
+
th: "th";
|
|
1493
|
+
tr: "tr";
|
|
1494
|
+
id: "id";
|
|
1495
|
+
is: "is";
|
|
1496
|
+
mt: "mt";
|
|
1497
|
+
ml: "ml";
|
|
1498
|
+
af: "af";
|
|
1499
|
+
sq: "sq";
|
|
1500
|
+
ar_dz: "ar_dz";
|
|
1501
|
+
ar_bh: "ar_bh";
|
|
1502
|
+
ar_eg: "ar_eg";
|
|
1503
|
+
ar_iq: "ar_iq";
|
|
1504
|
+
ar_jo: "ar_jo";
|
|
1505
|
+
ar_kw: "ar_kw";
|
|
1506
|
+
ar_lb: "ar_lb";
|
|
1507
|
+
ar_ly: "ar_ly";
|
|
1508
|
+
ar_ma: "ar_ma";
|
|
1509
|
+
ar_om: "ar_om";
|
|
1510
|
+
ar_qa: "ar_qa";
|
|
1511
|
+
ar_sa: "ar_sa";
|
|
1512
|
+
ar_sy: "ar_sy";
|
|
1513
|
+
ar_tn: "ar_tn";
|
|
1514
|
+
ar_ae: "ar_ae";
|
|
1515
|
+
ar_ye: "ar_ye";
|
|
1516
|
+
eu: "eu";
|
|
1517
|
+
be: "be";
|
|
1518
|
+
bg: "bg";
|
|
1519
|
+
ca: "ca";
|
|
1520
|
+
zh_hk: "zh_hk";
|
|
1521
|
+
zh_cn: "zh_cn";
|
|
1522
|
+
zh_sg: "zh_sg";
|
|
1523
|
+
zh_tw: "zh_tw";
|
|
1524
|
+
cs: "cs";
|
|
1525
|
+
da: "da";
|
|
1526
|
+
nl_be: "nl_be";
|
|
1527
|
+
nl: "nl";
|
|
1528
|
+
en: "en";
|
|
1529
|
+
en_au: "en_au";
|
|
1530
|
+
en_bz: "en_bz";
|
|
1531
|
+
en_ca: "en_ca";
|
|
1532
|
+
en_ie: "en_ie";
|
|
1533
|
+
en_jm: "en_jm";
|
|
1534
|
+
en_nz: "en_nz";
|
|
1535
|
+
en_za: "en_za";
|
|
1536
|
+
en_tt: "en_tt";
|
|
1537
|
+
en_gb: "en_gb";
|
|
1538
|
+
en_us: "en_us";
|
|
1539
|
+
et: "et";
|
|
1540
|
+
fo: "fo";
|
|
1541
|
+
fa: "fa";
|
|
1542
|
+
fi: "fi";
|
|
1543
|
+
fr_be: "fr_be";
|
|
1544
|
+
fr_ca: "fr_ca";
|
|
1545
|
+
fr_lu: "fr_lu";
|
|
1546
|
+
fr: "fr";
|
|
1547
|
+
fr_ch: "fr_ch";
|
|
1548
|
+
gd: "gd";
|
|
1549
|
+
de_at: "de_at";
|
|
1550
|
+
de_li: "de_li";
|
|
1551
|
+
de_lu: "de_lu";
|
|
1552
|
+
de: "de";
|
|
1553
|
+
de_ch: "de_ch";
|
|
1554
|
+
el: "el";
|
|
1555
|
+
he: "he";
|
|
1556
|
+
hi: "hi";
|
|
1557
|
+
hu: "hu";
|
|
1558
|
+
ga: "ga";
|
|
1559
|
+
it: "it";
|
|
1560
|
+
it_ch: "it_ch";
|
|
1561
|
+
ja: "ja";
|
|
1562
|
+
ko: "ko";
|
|
1563
|
+
ku: "ku";
|
|
1564
|
+
lv: "lv";
|
|
1565
|
+
lt: "lt";
|
|
1566
|
+
mk: "mk";
|
|
1567
|
+
ms: "ms";
|
|
1568
|
+
no: "no";
|
|
1569
|
+
nb: "nb";
|
|
1570
|
+
nn: "nn";
|
|
1571
|
+
pl: "pl";
|
|
1572
|
+
pt_br: "pt_br";
|
|
1573
|
+
pt: "pt";
|
|
1574
|
+
pa: "pa";
|
|
1575
|
+
rm: "rm";
|
|
1576
|
+
ro: "ro";
|
|
1577
|
+
ro_md: "ro_md";
|
|
1578
|
+
ru: "ru";
|
|
1579
|
+
ru_md: "ru_md";
|
|
1580
|
+
sr: "sr";
|
|
1581
|
+
sk: "sk";
|
|
1582
|
+
sl: "sl";
|
|
1583
|
+
sb: "sb";
|
|
1584
|
+
es_ar: "es_ar";
|
|
1585
|
+
es_bo: "es_bo";
|
|
1586
|
+
es_cl: "es_cl";
|
|
1587
|
+
es_co: "es_co";
|
|
1588
|
+
es_cr: "es_cr";
|
|
1589
|
+
es_do: "es_do";
|
|
1590
|
+
es_ec: "es_ec";
|
|
1591
|
+
es_sv: "es_sv";
|
|
1592
|
+
es_gt: "es_gt";
|
|
1593
|
+
es_hn: "es_hn";
|
|
1594
|
+
es_mx: "es_mx";
|
|
1595
|
+
es: "es";
|
|
1596
|
+
sv: "sv";
|
|
1597
|
+
sv_fi: "sv_fi";
|
|
1598
|
+
uk: "uk";
|
|
1599
|
+
ur: "ur";
|
|
1600
|
+
vi: "vi";
|
|
1601
|
+
cy: "cy";
|
|
1602
|
+
ji: "ji";
|
|
1603
|
+
zu: "zu";
|
|
1604
|
+
}>>;
|
|
1605
|
+
}, z.core.$strip>;
|
|
1606
|
+
};
|
|
1489
1607
|
responses: {
|
|
1490
1608
|
201: {
|
|
1491
1609
|
content: {
|
|
@@ -1704,7 +1822,7 @@ export declare const orderRoute: {
|
|
|
1704
1822
|
zipCode: z.ZodOptional<z.ZodString>;
|
|
1705
1823
|
city: z.ZodString;
|
|
1706
1824
|
country: z.ZodString;
|
|
1707
|
-
placeId: z.ZodString
|
|
1825
|
+
placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1708
1826
|
deliveryInstructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1709
1827
|
}, z.core.$strip>>>;
|
|
1710
1828
|
fulfilmentMethod: z.ZodEnum<{
|
|
@@ -1770,7 +1888,7 @@ export declare const orderRoute: {
|
|
|
1770
1888
|
shipping: z.ZodDefault<z.ZodNumber>;
|
|
1771
1889
|
subtotal: z.ZodNumber;
|
|
1772
1890
|
total: z.ZodNumber;
|
|
1773
|
-
discount: z.ZodDefault<z.ZodNumber
|
|
1891
|
+
discount: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodDefault<z.ZodNumber>>;
|
|
1774
1892
|
currency: z.ZodEnum<{
|
|
1775
1893
|
USD: "USD";
|
|
1776
1894
|
EUR: "EUR";
|
|
@@ -1905,13 +2023,13 @@ export declare const orderRoute: {
|
|
|
1905
2023
|
addressLineOne: string;
|
|
1906
2024
|
city: string;
|
|
1907
2025
|
country: string;
|
|
1908
|
-
placeId: string;
|
|
1909
2026
|
firstname?: string | null | undefined;
|
|
1910
2027
|
lastname?: string | null | undefined;
|
|
1911
2028
|
phone?: string | null | undefined;
|
|
1912
2029
|
doorNumber?: string | null | undefined;
|
|
1913
2030
|
addressLineTwo?: string | null | undefined;
|
|
1914
2031
|
zipCode?: string | undefined;
|
|
2032
|
+
placeId?: string | null | undefined;
|
|
1915
2033
|
deliveryInstructions?: string | null | undefined;
|
|
1916
2034
|
} | null | undefined;
|
|
1917
2035
|
}, {
|
|
@@ -2012,13 +2130,13 @@ export declare const orderRoute: {
|
|
|
2012
2130
|
addressLineOne: string;
|
|
2013
2131
|
city: string;
|
|
2014
2132
|
country: string;
|
|
2015
|
-
placeId: string;
|
|
2016
2133
|
firstname?: string | null | undefined;
|
|
2017
2134
|
lastname?: string | null | undefined;
|
|
2018
2135
|
phone?: string | null | undefined;
|
|
2019
2136
|
doorNumber?: string | null | undefined;
|
|
2020
2137
|
addressLineTwo?: string | null | undefined;
|
|
2021
2138
|
zipCode?: string | undefined;
|
|
2139
|
+
placeId?: string | null | undefined;
|
|
2022
2140
|
deliveryInstructions?: string | null | undefined;
|
|
2023
2141
|
} | null | undefined;
|
|
2024
2142
|
}>>;
|
|
@@ -2494,7 +2612,7 @@ export declare const orderRoute: {
|
|
|
2494
2612
|
zipCode: z.ZodOptional<z.ZodString>;
|
|
2495
2613
|
city: z.ZodString;
|
|
2496
2614
|
country: z.ZodString;
|
|
2497
|
-
placeId: z.ZodString
|
|
2615
|
+
placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2498
2616
|
deliveryInstructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
2499
2617
|
}, z.core.$strip>>>;
|
|
2500
2618
|
fulfilmentMethod: z.ZodEnum<{
|
|
@@ -2560,7 +2678,7 @@ export declare const orderRoute: {
|
|
|
2560
2678
|
shipping: z.ZodDefault<z.ZodNumber>;
|
|
2561
2679
|
subtotal: z.ZodNumber;
|
|
2562
2680
|
total: z.ZodNumber;
|
|
2563
|
-
discount: z.ZodDefault<z.ZodNumber
|
|
2681
|
+
discount: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodDefault<z.ZodNumber>>;
|
|
2564
2682
|
currency: z.ZodEnum<{
|
|
2565
2683
|
USD: "USD";
|
|
2566
2684
|
EUR: "EUR";
|
|
@@ -2695,13 +2813,13 @@ export declare const orderRoute: {
|
|
|
2695
2813
|
addressLineOne: string;
|
|
2696
2814
|
city: string;
|
|
2697
2815
|
country: string;
|
|
2698
|
-
placeId: string;
|
|
2699
2816
|
firstname?: string | null | undefined;
|
|
2700
2817
|
lastname?: string | null | undefined;
|
|
2701
2818
|
phone?: string | null | undefined;
|
|
2702
2819
|
doorNumber?: string | null | undefined;
|
|
2703
2820
|
addressLineTwo?: string | null | undefined;
|
|
2704
2821
|
zipCode?: string | undefined;
|
|
2822
|
+
placeId?: string | null | undefined;
|
|
2705
2823
|
deliveryInstructions?: string | null | undefined;
|
|
2706
2824
|
} | null | undefined;
|
|
2707
2825
|
}, {
|
|
@@ -2802,13 +2920,13 @@ export declare const orderRoute: {
|
|
|
2802
2920
|
addressLineOne: string;
|
|
2803
2921
|
city: string;
|
|
2804
2922
|
country: string;
|
|
2805
|
-
placeId: string;
|
|
2806
2923
|
firstname?: string | null | undefined;
|
|
2807
2924
|
lastname?: string | null | undefined;
|
|
2808
2925
|
phone?: string | null | undefined;
|
|
2809
2926
|
doorNumber?: string | null | undefined;
|
|
2810
2927
|
addressLineTwo?: string | null | undefined;
|
|
2811
2928
|
zipCode?: string | undefined;
|
|
2929
|
+
placeId?: string | null | undefined;
|
|
2812
2930
|
deliveryInstructions?: string | null | undefined;
|
|
2813
2931
|
} | null | undefined;
|
|
2814
2932
|
}>>;
|
|
@@ -3086,7 +3204,7 @@ export declare const orderRoute: {
|
|
|
3086
3204
|
zipCode: z.ZodOptional<z.ZodString>;
|
|
3087
3205
|
city: z.ZodString;
|
|
3088
3206
|
country: z.ZodString;
|
|
3089
|
-
placeId: z.ZodString
|
|
3207
|
+
placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
3090
3208
|
deliveryInstructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
3091
3209
|
}, z.core.$strip>>>;
|
|
3092
3210
|
fulfilmentMethod: z.ZodEnum<{
|
|
@@ -3152,7 +3270,7 @@ export declare const orderRoute: {
|
|
|
3152
3270
|
shipping: z.ZodDefault<z.ZodNumber>;
|
|
3153
3271
|
subtotal: z.ZodNumber;
|
|
3154
3272
|
total: z.ZodNumber;
|
|
3155
|
-
discount: z.ZodDefault<z.ZodNumber
|
|
3273
|
+
discount: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodDefault<z.ZodNumber>>;
|
|
3156
3274
|
currency: z.ZodEnum<{
|
|
3157
3275
|
USD: "USD";
|
|
3158
3276
|
EUR: "EUR";
|
|
@@ -3287,13 +3405,13 @@ export declare const orderRoute: {
|
|
|
3287
3405
|
addressLineOne: string;
|
|
3288
3406
|
city: string;
|
|
3289
3407
|
country: string;
|
|
3290
|
-
placeId: string;
|
|
3291
3408
|
firstname?: string | null | undefined;
|
|
3292
3409
|
lastname?: string | null | undefined;
|
|
3293
3410
|
phone?: string | null | undefined;
|
|
3294
3411
|
doorNumber?: string | null | undefined;
|
|
3295
3412
|
addressLineTwo?: string | null | undefined;
|
|
3296
3413
|
zipCode?: string | undefined;
|
|
3414
|
+
placeId?: string | null | undefined;
|
|
3297
3415
|
deliveryInstructions?: string | null | undefined;
|
|
3298
3416
|
} | null | undefined;
|
|
3299
3417
|
}, {
|
|
@@ -3394,13 +3512,13 @@ export declare const orderRoute: {
|
|
|
3394
3512
|
addressLineOne: string;
|
|
3395
3513
|
city: string;
|
|
3396
3514
|
country: string;
|
|
3397
|
-
placeId: string;
|
|
3398
3515
|
firstname?: string | null | undefined;
|
|
3399
3516
|
lastname?: string | null | undefined;
|
|
3400
3517
|
phone?: string | null | undefined;
|
|
3401
3518
|
doorNumber?: string | null | undefined;
|
|
3402
3519
|
addressLineTwo?: string | null | undefined;
|
|
3403
3520
|
zipCode?: string | undefined;
|
|
3521
|
+
placeId?: string | null | undefined;
|
|
3404
3522
|
deliveryInstructions?: string | null | undefined;
|
|
3405
3523
|
} | null | undefined;
|
|
3406
3524
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{z as r}from"@hono/zod-openapi";import{createApiRoute as t}from"../../core/hono/hono";import{
|
|
1
|
+
import{z as r}from"@hono/zod-openapi";import{createApiRoute as t}from"../../core/hono/hono";import{CreateOrderSchema as p,ErrorSchema as e,HeaderSchema as a,locale as m,OrderSchema as o,OrderStatusSchema as h,OrganizationParams as s,OrganizationWithIdParams as d,PaginationMetaSchema as n,PaginationQuerySchema as i}from"../../schemas";import{CartConflictSchema as c}from"../cart/cart.schema";const g=t({description:"Fetches paginated list of orders",headers:a,method:"GET",operationId:"getOrders",path:"/:organizationId/orders",pathParams:s,query:i,responses:{200:r.object({list:r.array(o),meta:n}),400:e,401:e},summary:"Get Orders",tags:["Order"]}),O=t({description:"Fetches paginated list of orders for the authenticated user",headers:a,method:"GET",operationId:"getMyOrders",path:"/:organizationId/orders/me",pathParams:s,query:i,responses:{200:r.object({list:r.array(o),meta:n}),400:e,401:e},summary:"Get My Orders",tags:["Order"]}),u=t({body:p,description:"Creates a new order",headers:a,method:"POST",operationId:"createOrder",path:"/:organizationId/orders",pathParams:r.object({organizationId:r.string().cuid().min(1).openapi({description:"The organization ID",example:"ckel0e8qw00004n5p5w6fznym",param:{in:"path",name:"organizationId"}})}),query:r.object({locale:m.optional()}),responses:{201:r.object({order:o,redirectUrl:r.string().url().optional()}),409:c,400:e,401:e,404:e},summary:"Create Order",tags:["Order"]}),l=t({headers:a,method:"GET",operationId:"getOrder",path:"/:organizationId/orders/:id",pathParams:d,responses:{200:o,401:e,404:e},summary:"Get Order",tags:["Order"]}),y=t({description:"Changes the status of an existing order based on the operation",headers:a,method:"POST",operationId:"updateOrderStatus",path:"/:organizationId/orders/:id/status/:operation",pathParams:d.extend({operation:h}),responses:{200:o,400:e,401:e,404:e},summary:"Change Order Status",tags:["Order"]}),I=t({description:"Soft deletes order",headers:a,method:"DELETE",operationId:"deleteOrder",path:"/:organizationId/orders/:id",pathParams:d,responses:{204:null,400:e,401:e,404:e},summary:"Delete Order",tags:["Order"]});export const orderRoute={getOrders:g,getMyOrders:O,createOrder:u,getOrder:l,updateStatus:y,deleteOrder:I};
|
|
@@ -371,7 +371,7 @@ export declare const OrderSchema: z.ZodPipe<z.ZodObject<{
|
|
|
371
371
|
zipCode: z.ZodOptional<z.ZodString>;
|
|
372
372
|
city: z.ZodString;
|
|
373
373
|
country: z.ZodString;
|
|
374
|
-
placeId: z.ZodString
|
|
374
|
+
placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
375
375
|
deliveryInstructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
376
376
|
}, z.core.$strip>>>;
|
|
377
377
|
fulfilmentMethod: z.ZodEnum<{
|
|
@@ -437,7 +437,7 @@ export declare const OrderSchema: z.ZodPipe<z.ZodObject<{
|
|
|
437
437
|
shipping: z.ZodDefault<z.ZodNumber>;
|
|
438
438
|
subtotal: z.ZodNumber;
|
|
439
439
|
total: z.ZodNumber;
|
|
440
|
-
discount: z.ZodDefault<z.ZodNumber
|
|
440
|
+
discount: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodDefault<z.ZodNumber>>;
|
|
441
441
|
currency: z.ZodEnum<{
|
|
442
442
|
USD: "USD";
|
|
443
443
|
EUR: "EUR";
|
|
@@ -572,13 +572,13 @@ export declare const OrderSchema: z.ZodPipe<z.ZodObject<{
|
|
|
572
572
|
addressLineOne: string;
|
|
573
573
|
city: string;
|
|
574
574
|
country: string;
|
|
575
|
-
placeId: string;
|
|
576
575
|
firstname?: string | null | undefined;
|
|
577
576
|
lastname?: string | null | undefined;
|
|
578
577
|
phone?: string | null | undefined;
|
|
579
578
|
doorNumber?: string | null | undefined;
|
|
580
579
|
addressLineTwo?: string | null | undefined;
|
|
581
580
|
zipCode?: string | undefined;
|
|
581
|
+
placeId?: string | null | undefined;
|
|
582
582
|
deliveryInstructions?: string | null | undefined;
|
|
583
583
|
} | null | undefined;
|
|
584
584
|
}, {
|
|
@@ -679,13 +679,13 @@ export declare const OrderSchema: z.ZodPipe<z.ZodObject<{
|
|
|
679
679
|
addressLineOne: string;
|
|
680
680
|
city: string;
|
|
681
681
|
country: string;
|
|
682
|
-
placeId: string;
|
|
683
682
|
firstname?: string | null | undefined;
|
|
684
683
|
lastname?: string | null | undefined;
|
|
685
684
|
phone?: string | null | undefined;
|
|
686
685
|
doorNumber?: string | null | undefined;
|
|
687
686
|
addressLineTwo?: string | null | undefined;
|
|
688
687
|
zipCode?: string | undefined;
|
|
688
|
+
placeId?: string | null | undefined;
|
|
689
689
|
deliveryInstructions?: string | null | undefined;
|
|
690
690
|
} | null | undefined;
|
|
691
691
|
}>>;
|
|
@@ -2,7 +2,7 @@ import { z } from "@hono/zod-openapi";
|
|
|
2
2
|
import { HttpException } from "../../core/exceptions/http-exception";
|
|
3
3
|
import { PrismaClientType } from "../../core/lib/prisma";
|
|
4
4
|
import { EmailService } from "../../core/notifications/email.service";
|
|
5
|
-
import { CreateOrderSchema, OrderStatus, User } from "../../schemas";
|
|
5
|
+
import { CreateOrderSchema, Locale, OrderStatus, User } from "../../schemas";
|
|
6
6
|
import { CartData } from "../cart/cart.schema";
|
|
7
7
|
import { CartService } from "../cart/cart.service";
|
|
8
8
|
import { PaymentService } from "../payment/payment.service";
|
|
@@ -20,10 +20,16 @@ declare class OrderService {
|
|
|
20
20
|
private readonly cartService;
|
|
21
21
|
private readonly emailService;
|
|
22
22
|
constructor(prisma: PrismaClientType, paymentService: PaymentService, cartService: CartService, emailService: EmailService);
|
|
23
|
+
private safelySendEmail;
|
|
24
|
+
private toLocaleCandidates;
|
|
25
|
+
private resolveCheckoutLocale;
|
|
23
26
|
/**
|
|
24
27
|
* Create a draft order
|
|
25
28
|
*/
|
|
26
|
-
createOrder(organizationId: string, user: User, body: z.infer<typeof CreateOrderSchema
|
|
29
|
+
createOrder(organizationId: string, user: User, body: z.infer<typeof CreateOrderSchema>, options?: {
|
|
30
|
+
acceptLanguage?: string;
|
|
31
|
+
locale?: Locale;
|
|
32
|
+
}): Promise<{
|
|
27
33
|
redirectUrl: string | undefined;
|
|
28
34
|
order: {
|
|
29
35
|
status: "pending" | "accepted" | "ready-for-dispatch" | "dispatched" | "completed" | "cancelled";
|
|
@@ -123,13 +129,13 @@ declare class OrderService {
|
|
|
123
129
|
addressLineOne: string;
|
|
124
130
|
city: string;
|
|
125
131
|
country: string;
|
|
126
|
-
placeId: string;
|
|
127
132
|
firstname?: string | null | undefined;
|
|
128
133
|
lastname?: string | null | undefined;
|
|
129
134
|
phone?: string | null | undefined;
|
|
130
135
|
doorNumber?: string | null | undefined;
|
|
131
136
|
addressLineTwo?: string | null | undefined;
|
|
132
137
|
zipCode?: string | undefined;
|
|
138
|
+
placeId?: string | null | undefined;
|
|
133
139
|
deliveryInstructions?: string | null | undefined;
|
|
134
140
|
} | null | undefined;
|
|
135
141
|
};
|
|
@@ -237,13 +243,13 @@ declare class OrderService {
|
|
|
237
243
|
addressLineOne: string;
|
|
238
244
|
city: string;
|
|
239
245
|
country: string;
|
|
240
|
-
placeId: string;
|
|
241
246
|
firstname?: string | null | undefined;
|
|
242
247
|
lastname?: string | null | undefined;
|
|
243
248
|
phone?: string | null | undefined;
|
|
244
249
|
doorNumber?: string | null | undefined;
|
|
245
250
|
addressLineTwo?: string | null | undefined;
|
|
246
251
|
zipCode?: string | undefined;
|
|
252
|
+
placeId?: string | null | undefined;
|
|
247
253
|
deliveryInstructions?: string | null | undefined;
|
|
248
254
|
} | null | undefined;
|
|
249
255
|
}>;
|
|
@@ -359,13 +365,13 @@ declare class OrderService {
|
|
|
359
365
|
addressLineOne: string;
|
|
360
366
|
city: string;
|
|
361
367
|
country: string;
|
|
362
|
-
placeId: string;
|
|
363
368
|
firstname?: string | null | undefined;
|
|
364
369
|
lastname?: string | null | undefined;
|
|
365
370
|
phone?: string | null | undefined;
|
|
366
371
|
doorNumber?: string | null | undefined;
|
|
367
372
|
addressLineTwo?: string | null | undefined;
|
|
368
373
|
zipCode?: string | undefined;
|
|
374
|
+
placeId?: string | null | undefined;
|
|
369
375
|
deliveryInstructions?: string | null | undefined;
|
|
370
376
|
} | null | undefined;
|
|
371
377
|
}[];
|
|
@@ -484,13 +490,13 @@ declare class OrderService {
|
|
|
484
490
|
addressLineOne: string;
|
|
485
491
|
city: string;
|
|
486
492
|
country: string;
|
|
487
|
-
placeId: string;
|
|
488
493
|
firstname?: string | null | undefined;
|
|
489
494
|
lastname?: string | null | undefined;
|
|
490
495
|
phone?: string | null | undefined;
|
|
491
496
|
doorNumber?: string | null | undefined;
|
|
492
497
|
addressLineTwo?: string | null | undefined;
|
|
493
498
|
zipCode?: string | undefined;
|
|
499
|
+
placeId?: string | null | undefined;
|
|
494
500
|
deliveryInstructions?: string | null | undefined;
|
|
495
501
|
} | null | undefined;
|
|
496
502
|
}[];
|
|
@@ -600,13 +606,13 @@ declare class OrderService {
|
|
|
600
606
|
addressLineOne: string;
|
|
601
607
|
city: string;
|
|
602
608
|
country: string;
|
|
603
|
-
placeId: string;
|
|
604
609
|
firstname?: string | null | undefined;
|
|
605
610
|
lastname?: string | null | undefined;
|
|
606
611
|
phone?: string | null | undefined;
|
|
607
612
|
doorNumber?: string | null | undefined;
|
|
608
613
|
addressLineTwo?: string | null | undefined;
|
|
609
614
|
zipCode?: string | undefined;
|
|
615
|
+
placeId?: string | null | undefined;
|
|
610
616
|
deliveryInstructions?: string | null | undefined;
|
|
611
617
|
} | null | undefined;
|
|
612
618
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as
|
|
1
|
+
import{__awaiter as l}from"tslib";import{z as O}from"@hono/zod-openapi";import{customAlphabet as U}from"nanoid";import{HttpException as m}from"../../core/exceptions/http-exception";import{logger as D}from"../../core/logging/pino";import{OrderSchema as p,OrganizationSchema as Z,PaginationMetaSchema as A,UserSchema as I,localeMap as F}from"../../schemas";import{transformCartItemToOrderItem as E}from"../cart/cart.util";const S=U("1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ",6);class z extends m{constructor(t){super(409,t.message),this.payload=t}}class _{constructor(t,i,e,r){this.prisma=t,this.paymentService=i,this.cartService=e,this.emailService=r}safelySendEmail(t,i){return l(this,void 0,void 0,function*(){try{yield i()}catch(e){D.error(Object.assign({err:e},t),"Email delivery failed")}})}toLocaleCandidates(t){const i=t.trim().toLowerCase().replace(/-/g,"_");if(!i)return[];const[e]=i.split("_");return!e||e===i?[i]:[i,e]}resolveCheckoutLocale(t,i,e,r){const n=new Set(e);if(t&&n.has(t))return t;if(!i)return r;const d=i.split(",").map((s,a)=>{const[o,...c]=s.trim().split(";"),g=c.find(f=>f.trim().startsWith("q=")),u=g?Number.parseFloat(g.trim().slice(2)):1;return{index:a,quality:Number.isFinite(u)?u:0,rawLocale:o}}).filter(s=>s.rawLocale).sort((s,a)=>a.quality!==s.quality?a.quality-s.quality:s.index-a.index);for(const s of d)for(const a of this.toLocaleCandidates(s.rawLocale))if(F.has(a)&&n.has(a))return a;return r}createOrder(t,i,e,r){return l(this,void 0,void 0,function*(){var n,d,s,a,o;const c=yield this.prisma.organization.findFirst({where:{id:t},include:{configuration:!0}});if(!c)throw new m(404,"Organization not found");const g=this.resolveCheckoutLocale(r?.locale,r?.acceptLanguage,c.configuration.supportedLocales,c.configuration.defaultLocale),u=yield this.cartService.getCartData(t,e,{locale:g});if(u.invalidProductIds.length>0||this.hasCartConflict(e.items,u.normalizedItems))throw new z(Object.assign(Object.assign({},u),{message:"Some items in your cart are no longer available in the requested quantity."}));const f=yield this.prisma.address.findFirst({where:{users:{some:{id:i.id}},isDefault:!0}});if(e.fulfilmentMethod==="delivery"&&!f)throw new m(400,"This user does not have a default shipping address");const y=yield Promise.all(u.normalizedItems.map(E(this.prisma))),h=yield this.prisma.shippingMethod.findFirst({where:{id:e.shippingMethodId},include:{shippingZones:!0}}),C=(d=(n=h?.shippingZones[0])===null||n===void 0?void 0:n.price)!==null&&d!==void 0?d:0,w=y.reduce((q,k)=>q+k.totalPrice,0),L=w+C,v=yield this.prisma.order.create({data:Object.assign(Object.assign({token:S(),referenceId:S(),organization:{connect:{id:t}},fulfilmentMethod:e.fulfilmentMethod,shippingMethod:e.shippingMethodId?{connect:{id:e.shippingMethodId}}:void 0,currency:c.configuration.defaultCurrency,sourceIp:"127.0.0.1",items:{create:y}},f?{shippingAddress:{create:Object.assign(Object.assign({},f),{id:void 0})}}:{}),{user:{connect:{id:i.id}},payment:{create:{method:e.payment.method,provider:e.payment.provider,shipping:(a=(s=h?.shippingZones[0])===null||s===void 0?void 0:s.price)!==null&&a!==void 0?a:0,subtotal:w,total:L,discount:0,currency:c.configuration.defaultCurrency}}}),include:{items:{include:{translations:!0,image:!0}},payment:!0,shippingMethod:{include:{shippingZones:!0}}}}),b=p.parse(v);return{redirectUrl:(o=(yield this.paymentService.createCheckoutSession(t,i,b,{locale:g,defaultLocale:c.configuration.defaultLocale,successUrl:`${e.checkoutBaseUrl}/account/orders/${v.id}?clearCart=true`,cancelUrl:`${e.checkoutBaseUrl}/checkout/shipping-and-payment`})).redirectUrl)!==null&&o!==void 0?o:void 0,order:p.parse(v)}})}hasCartConflict(t,i){return JSON.stringify(t)!==JSON.stringify(i)}sendOrderNotifications(t,i){return l(this,void 0,void 0,function*(){const e=yield this.prisma.order.findFirst({where:{id:t},include:{items:{include:{translations:!0,image:!0}},payment:!0,organization:{include:{address:!0,configuration:!0,logoFile:!0,members:{include:{user:!0}}}},shippingAddress:!0,shippingMethod:{include:{shippingZones:!0}}}}),r=i??e?.userId,n=r?yield this.prisma.user.findFirst({where:{id:r}}):null;if(!e||!n)return;const d=I.parse(n),s=Z.parse(e.organization),a=p.parse(e);yield this.safelySendEmail({emailType:"order-confirmation",orderId:e.id,organizationId:e.organizationId,userId:n.id},()=>this.emailService.sendOrderConfirmationEmail(e.organizationId,d,s,a));for(const o of e.organization.members)yield this.safelySendEmail({emailType:"order-notification",memberId:o.user.id,orderId:e.id,organizationId:e.organizationId,userId:n.id},()=>this.emailService.sendOrderNotificationEmail(e.organizationId,d,I.parse(o.user),s,a))})}getOrder(t,i,e){return l(this,void 0,void 0,function*(){const r=yield this.prisma.order.findUnique({where:{id:e,organizationId:i,deletedAt:null,user:{id:t.id}},include:{items:{include:{translations:!0,image:!0}},shippingAddress:!0,shippingMethod:{include:{shippingZones:!0}},payment:!0}});if(!r)throw new m(404,"Order not found");return p.parse(r)})}getMyOrders(t,i,e){return l(this,void 0,void 0,function*(){const{page:r=1,limit:n=10,search:d}=e,[s,a]=yield this.prisma.order.paginate({where:Object.assign({organizationId:i,userId:t,deletedAt:null},d?{referenceId:{contains:d,mode:"insensitive"}}:{}),include:{items:{include:{translations:!0,image:!0}},shippingAddress:!0,shippingMethod:{include:{shippingZones:!0}},payment:!0},orderBy:{createdAt:"desc"}}).withPages({page:r,limit:n});return{meta:A.parse(a),list:O.array(p).parse(s)}})}getOrders(t,i){return l(this,void 0,void 0,function*(){const{page:e=1,limit:r=10}=i,[n,d]=yield this.prisma.order.paginate({where:{organizationId:t,deletedAt:null},include:{items:{include:{translations:!0,image:!0}},shippingAddress:!0,shippingMethod:{include:{shippingZones:!0}},payment:!0},orderBy:{createdAt:"desc"}}).withPages({page:e,limit:r});return{meta:A.parse(d),list:O.array(p).parse(n)}})}deleteOrder(t,i,e){return l(this,void 0,void 0,function*(){if(!(yield this.prisma.order.findUnique({where:{id:i,organizationId:t,deletedAt:null}})))throw new m(404,"Order not found");yield this.prisma.order.update({where:{id:i,organizationId:t,deletedAt:null},data:{deletedAt:new Date,deletedBy:e}})})}updateStatus(t,i,e){return l(this,void 0,void 0,function*(){if(!(yield this.prisma.order.findUnique({where:{id:i,organizationId:t,deletedAt:null},include:{items:!0,shippingMethod:{include:{shippingZones:!0}}}})))throw new m(404,"Order not found");let n={};switch(e){case"accepted":n={acceptedAt:new Date};break;case"ready-for-dispatch":n={readyForDispatchAt:new Date};break;case"dispatched":n={dispatchedAt:new Date};break;case"completed":n={completedAt:new Date};break;case"cancelled":n={cancelledAt:new Date};break}const d=yield this.prisma.order.update({where:{id:i},data:n,include:{items:{include:{translations:!0,image:!0}},shippingAddress:!0,shippingMethod:{include:{shippingZones:!0}},payment:!0}});return p.parse(d)})}}export{_ as OrderService};export{z as OrderInventoryConflictError};
|
|
@@ -15,7 +15,7 @@ export declare const RecipientSchema: z.ZodObject<{
|
|
|
15
15
|
zipCode: z.ZodOptional<z.ZodString>;
|
|
16
16
|
city: z.ZodString;
|
|
17
17
|
country: z.ZodString;
|
|
18
|
-
placeId: z.ZodString
|
|
18
|
+
placeId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
19
19
|
deliveryInstructions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
20
20
|
}, z.core.$strip>>>;
|
|
21
21
|
createdAt: z.ZodDate;
|
|
@@ -17,7 +17,7 @@ export declare const LegalEntitySchema: z.ZodObject<{
|
|
|
17
17
|
zipCode: z.ZodNonOptional<z.ZodOptional<z.ZodString>>;
|
|
18
18
|
city: z.ZodNonOptional<z.ZodString>;
|
|
19
19
|
country: z.ZodNonOptional<z.ZodString>;
|
|
20
|
-
placeId: z.ZodNonOptional<z.ZodString
|
|
20
|
+
placeId: z.ZodNonOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
21
21
|
deliveryInstructions: z.ZodNonOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
22
22
|
}, z.core.$strip>;
|
|
23
23
|
}, z.core.$strip>;
|
|
@@ -307,7 +307,6 @@ export declare const OrganizationConfigurationSchema: z.ZodObject<{
|
|
|
307
307
|
createdAt: z.ZodDate;
|
|
308
308
|
}, z.core.$strip>;
|
|
309
309
|
export declare const UpdateOrganizationConfigurationSchema: z.ZodObject<{
|
|
310
|
-
hostname: z.ZodOptional<z.ZodOptional<z.ZodCoercedString<unknown>>>;
|
|
311
310
|
openingTimes: z.ZodOptional<z.ZodOptional<z.ZodObject<{
|
|
312
311
|
monday: z.ZodNullable<z.ZodString>;
|
|
313
312
|
tuesday: z.ZodNullable<z.ZodString>;
|
|
@@ -326,6 +325,7 @@ export declare const UpdateOrganizationConfigurationSchema: z.ZodObject<{
|
|
|
326
325
|
saturday: z.ZodNullable<z.ZodString>;
|
|
327
326
|
sunday: z.ZodNullable<z.ZodString>;
|
|
328
327
|
}, z.core.$strip>>>;
|
|
328
|
+
hostname: z.ZodOptional<z.ZodOptional<z.ZodCoercedString<unknown>>>;
|
|
329
329
|
defaultLocale: z.ZodOptional<z.ZodEnum<{
|
|
330
330
|
hr: "hr";
|
|
331
331
|
th: "th";
|