@voyantjs/transactions 0.3.0 → 0.4.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/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/service.d.ts +3 -0
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +3 -0
- package/dist/storefront-offers.d.ts +108 -0
- package/dist/storefront-offers.d.ts.map +1 -0
- package/dist/storefront-offers.js +216 -0
- package/dist/validation.d.ts +90 -2
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +26 -2
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type { DecryptedTransactionParticipantIdentity, TransactionParticipantIde
|
|
|
16
16
|
export { decryptedTransactionParticipantIdentitySchema, transactionParticipantIdentityEnvelopeSchema, transactionParticipantIdentitySchema, } from "./schema/participant-identity.js";
|
|
17
17
|
export type { NewOffer, NewOfferItem, NewOfferItemParticipant, NewOfferParticipant, NewOrder, NewOrderItem, NewOrderItemParticipant, NewOrderParticipant, NewOrderTerm, Offer, OfferItem, OfferItemParticipant, OfferParticipant, Order, OrderItem, OrderItemParticipant, OrderParticipant, OrderTerm, } from "./schema.js";
|
|
18
18
|
export { offerItemParticipants, offerItems, offerParticipants, offerStatusEnum, offers, orderItemParticipants, orderItems, orderParticipants, orderStatusEnum, orders, orderTermAcceptanceStatusEnum, orderTerms, orderTermTypeEnum, transactionItemParticipantRoleEnum, transactionItemStatusEnum, transactionItemTypeEnum, transactionParticipantTypeEnum, transactionPiiAccessActionEnum, transactionPiiAccessLog, transactionPiiAccessOutcomeEnum, transactionTravelerCategoryEnum, } from "./schema.js";
|
|
19
|
-
export {
|
|
19
|
+
export { createStorefrontPromotionalOffersResolver, getStorefrontPromotionalOfferBySlug, listStorefrontPromotionalOffers, storefrontOfferEnvelopeSchema, storefrontPromotionalOfferSchema, } from "./storefront-offers.js";
|
|
20
|
+
export { insertOfferItemParticipantSchema, insertOfferItemSchema, insertOfferParticipantSchema, insertOfferSchema, insertOrderItemParticipantSchema, insertOrderItemSchema, insertOrderParticipantSchema, insertOrderSchema, insertOrderTermSchema, offerItemListQuerySchema, offerItemParticipantListQuerySchema, offerListQuerySchema, offerMetadataSchema, offerParticipantListQuerySchema, offerStatusSchema, orderItemListQuerySchema, orderItemParticipantListQuerySchema, orderListQuerySchema, orderParticipantListQuerySchema, orderStatusSchema, orderTermAcceptanceStatusSchema, orderTermListQuerySchema, orderTermTypeSchema, storefrontOfferDiscountTypeSchema, storefrontOfferMetadataSchema, transactionItemParticipantRoleSchema, transactionItemStatusSchema, transactionItemTypeSchema, transactionParticipantTypeSchema, transactionTravelerCategorySchema, updateOfferItemParticipantSchema, updateOfferItemSchema, updateOfferParticipantSchema, updateOfferSchema, updateOrderItemParticipantSchema, updateOrderItemSchema, updateOrderParticipantSchema, updateOrderSchema, updateOrderTermSchema, } from "./validation.js";
|
|
20
21
|
export { transactionsService };
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EACL,2BAA2B,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,yCAAyC,GAC/C,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAElD,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,eAAO,MAAM,aAAa,EAAE,kBAK3B,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,kBAK3B,CAAA;AAED,eAAO,MAAM,oB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AAmB,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -28,5 +28,6 @@ export const transactionsHonoModule = {
|
|
|
28
28
|
export { transactionsBookingExtension } from "./booking-extension.js";
|
|
29
29
|
export { decryptedTransactionParticipantIdentitySchema, transactionParticipantIdentityEnvelopeSchema, transactionParticipantIdentitySchema, } from "./schema/participant-identity.js";
|
|
30
30
|
export { offerItemParticipants, offerItems, offerParticipants, offerStatusEnum, offers, orderItemParticipants, orderItems, orderParticipants, orderStatusEnum, orders, orderTermAcceptanceStatusEnum, orderTerms, orderTermTypeEnum, transactionItemParticipantRoleEnum, transactionItemStatusEnum, transactionItemTypeEnum, transactionParticipantTypeEnum, transactionPiiAccessActionEnum, transactionPiiAccessLog, transactionPiiAccessOutcomeEnum, transactionTravelerCategoryEnum, } from "./schema.js";
|
|
31
|
-
export {
|
|
31
|
+
export { createStorefrontPromotionalOffersResolver, getStorefrontPromotionalOfferBySlug, listStorefrontPromotionalOffers, storefrontOfferEnvelopeSchema, storefrontPromotionalOfferSchema, } from "./storefront-offers.js";
|
|
32
|
+
export { insertOfferItemParticipantSchema, insertOfferItemSchema, insertOfferParticipantSchema, insertOfferSchema, insertOrderItemParticipantSchema, insertOrderItemSchema, insertOrderParticipantSchema, insertOrderSchema, insertOrderTermSchema, offerItemListQuerySchema, offerItemParticipantListQuerySchema, offerListQuerySchema, offerMetadataSchema, offerParticipantListQuerySchema, offerStatusSchema, orderItemListQuerySchema, orderItemParticipantListQuerySchema, orderListQuerySchema, orderParticipantListQuerySchema, orderStatusSchema, orderTermAcceptanceStatusSchema, orderTermListQuerySchema, orderTermTypeSchema, storefrontOfferDiscountTypeSchema, storefrontOfferMetadataSchema, transactionItemParticipantRoleSchema, transactionItemStatusSchema, transactionItemTypeSchema, transactionParticipantTypeSchema, transactionTravelerCategorySchema, updateOfferItemParticipantSchema, updateOfferItemSchema, updateOfferParticipantSchema, updateOfferSchema, updateOrderItemParticipantSchema, updateOrderItemSchema, updateOrderParticipantSchema, updateOrderSchema, updateOrderTermSchema, } from "./validation.js";
|
|
32
33
|
export { transactionsService };
|
package/dist/service.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createOffer, createOfferBundle, createOfferItem, createOfferItemParticipant, createOfferParticipant, deleteOffer, deleteOfferItem, deleteOfferItemParticipant, deleteOfferParticipant, getOfferById, getOfferItemById, getOfferItemParticipantById, getOfferParticipantById, listOfferItemParticipants, listOfferItems, listOfferParticipants, listOffers, updateOffer, updateOfferItem, updateOfferItemParticipant, updateOfferParticipant } from "./service-offers.js";
|
|
2
2
|
import { createOrder, createOrderItem, createOrderItemParticipant, createOrderParticipant, createOrderTerm, deleteOrder, deleteOrderItem, deleteOrderItemParticipant, deleteOrderParticipant, deleteOrderTerm, getOrderById, getOrderItemById, getOrderItemParticipantById, getOrderParticipantById, getOrderTermById, listOrderItemParticipants, listOrderItems, listOrderParticipants, listOrders, listOrderTerms, updateOrder, updateOrderItem, updateOrderItemParticipant, updateOrderParticipant, updateOrderTerm } from "./service-orders.js";
|
|
3
|
+
import { getStorefrontPromotionalOfferBySlug, listStorefrontPromotionalOffers } from "./storefront-offers.js";
|
|
3
4
|
export declare const transactionsService: {
|
|
4
5
|
listOffers: typeof listOffers;
|
|
6
|
+
listStorefrontPromotionalOffers: typeof listStorefrontPromotionalOffers;
|
|
7
|
+
getStorefrontPromotionalOfferBySlug: typeof getStorefrontPromotionalOfferBySlug;
|
|
5
8
|
getOfferById: typeof getOfferById;
|
|
6
9
|
createOffer: typeof createOffer;
|
|
7
10
|
createOfferBundle: typeof createOfferBundle;
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,EACvB,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,UAAU,EACV,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,EACvB,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,UAAU,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,EAChB,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,EACvB,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,UAAU,EACV,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,EACf,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,uBAAuB,EACvB,gBAAgB,EAChB,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,UAAU,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,sBAAsB,EACtB,eAAe,EAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,mCAAmC,EACnC,+BAA+B,EAChC,MAAM,wBAAwB,CAAA;AAE/B,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiD/B,CAAA"}
|
package/dist/service.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createOffer, createOfferBundle, createOfferItem, createOfferItemParticipant, createOfferParticipant, deleteOffer, deleteOfferItem, deleteOfferItemParticipant, deleteOfferParticipant, getOfferById, getOfferItemById, getOfferItemParticipantById, getOfferParticipantById, listOfferItemParticipants, listOfferItems, listOfferParticipants, listOffers, updateOffer, updateOfferItem, updateOfferItemParticipant, updateOfferParticipant, } from "./service-offers.js";
|
|
2
2
|
import { createOrder, createOrderItem, createOrderItemParticipant, createOrderParticipant, createOrderTerm, deleteOrder, deleteOrderItem, deleteOrderItemParticipant, deleteOrderParticipant, deleteOrderTerm, getOrderById, getOrderItemById, getOrderItemParticipantById, getOrderParticipantById, getOrderTermById, listOrderItemParticipants, listOrderItems, listOrderParticipants, listOrders, listOrderTerms, updateOrder, updateOrderItem, updateOrderItemParticipant, updateOrderParticipant, updateOrderTerm, } from "./service-orders.js";
|
|
3
|
+
import { getStorefrontPromotionalOfferBySlug, listStorefrontPromotionalOffers, } from "./storefront-offers.js";
|
|
3
4
|
export const transactionsService = {
|
|
4
5
|
listOffers,
|
|
6
|
+
listStorefrontPromotionalOffers,
|
|
7
|
+
getStorefrontPromotionalOfferBySlug,
|
|
5
8
|
getOfferById,
|
|
6
9
|
createOffer,
|
|
7
10
|
createOfferBundle,
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { storefrontOfferMetadataSchema } from "./validation.js";
|
|
4
|
+
export declare const storefrontOfferEnvelopeSchema: z.ZodObject<{
|
|
5
|
+
storefrontPromotionalOffer: z.ZodObject<{
|
|
6
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
locale: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
8
|
+
slug: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
9
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
10
|
+
discountType: z.ZodEnum<{
|
|
11
|
+
percentage: "percentage";
|
|
12
|
+
fixed_amount: "fixed_amount";
|
|
13
|
+
}>;
|
|
14
|
+
discountValue: z.ZodString;
|
|
15
|
+
currency: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
16
|
+
applicableProductIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
17
|
+
applicableDepartureIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
18
|
+
validFrom: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
19
|
+
validTo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
20
|
+
minPassengers: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
21
|
+
imageMobileUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
22
|
+
imageDesktopUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
23
|
+
stackable: z.ZodDefault<z.ZodBoolean>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export declare const storefrontPromotionalOfferSchema: z.ZodObject<{
|
|
27
|
+
id: z.ZodString;
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
slug: z.ZodNullable<z.ZodString>;
|
|
30
|
+
description: z.ZodNullable<z.ZodString>;
|
|
31
|
+
discountType: z.ZodEnum<{
|
|
32
|
+
percentage: "percentage";
|
|
33
|
+
fixed_amount: "fixed_amount";
|
|
34
|
+
}>;
|
|
35
|
+
discountValue: z.ZodString;
|
|
36
|
+
currency: z.ZodNullable<z.ZodString>;
|
|
37
|
+
applicableProductIds: z.ZodArray<z.ZodString>;
|
|
38
|
+
applicableDepartureIds: z.ZodArray<z.ZodString>;
|
|
39
|
+
validFrom: z.ZodNullable<z.ZodString>;
|
|
40
|
+
validTo: z.ZodNullable<z.ZodString>;
|
|
41
|
+
minPassengers: z.ZodNullable<z.ZodNumber>;
|
|
42
|
+
imageMobileUrl: z.ZodNullable<z.ZodString>;
|
|
43
|
+
imageDesktopUrl: z.ZodNullable<z.ZodString>;
|
|
44
|
+
stackable: z.ZodBoolean;
|
|
45
|
+
createdAt: z.ZodString;
|
|
46
|
+
updatedAt: z.ZodString;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type StorefrontOfferMetadata = z.infer<typeof storefrontOfferMetadataSchema>;
|
|
49
|
+
export type StorefrontPromotionalOffer = z.infer<typeof storefrontPromotionalOfferSchema>;
|
|
50
|
+
export declare function listStorefrontPromotionalOffers(db: PostgresJsDatabase, input: {
|
|
51
|
+
productId: string;
|
|
52
|
+
departureId?: string;
|
|
53
|
+
locale?: string;
|
|
54
|
+
now?: Date;
|
|
55
|
+
}): Promise<StorefrontPromotionalOffer[]>;
|
|
56
|
+
export declare function getStorefrontPromotionalOfferBySlug(db: PostgresJsDatabase, input: {
|
|
57
|
+
slug: string;
|
|
58
|
+
locale?: string;
|
|
59
|
+
now?: Date;
|
|
60
|
+
}): Promise<StorefrontPromotionalOffer | null>;
|
|
61
|
+
export declare function createStorefrontPromotionalOffersResolver(db: PostgresJsDatabase): {
|
|
62
|
+
listApplicableOffers(input: {
|
|
63
|
+
productId: string;
|
|
64
|
+
departureId?: string;
|
|
65
|
+
locale?: string;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
id: string;
|
|
68
|
+
name: string;
|
|
69
|
+
slug: string | null;
|
|
70
|
+
description: string | null;
|
|
71
|
+
discountType: "percentage" | "fixed_amount";
|
|
72
|
+
discountValue: string;
|
|
73
|
+
currency: string | null;
|
|
74
|
+
applicableProductIds: string[];
|
|
75
|
+
applicableDepartureIds: string[];
|
|
76
|
+
validFrom: string | null;
|
|
77
|
+
validTo: string | null;
|
|
78
|
+
minPassengers: number | null;
|
|
79
|
+
imageMobileUrl: string | null;
|
|
80
|
+
imageDesktopUrl: string | null;
|
|
81
|
+
stackable: boolean;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
updatedAt: string;
|
|
84
|
+
}[]>;
|
|
85
|
+
getOfferBySlug(input: {
|
|
86
|
+
slug: string;
|
|
87
|
+
locale?: string;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
slug: string | null;
|
|
92
|
+
description: string | null;
|
|
93
|
+
discountType: "percentage" | "fixed_amount";
|
|
94
|
+
discountValue: string;
|
|
95
|
+
currency: string | null;
|
|
96
|
+
applicableProductIds: string[];
|
|
97
|
+
applicableDepartureIds: string[];
|
|
98
|
+
validFrom: string | null;
|
|
99
|
+
validTo: string | null;
|
|
100
|
+
minPassengers: number | null;
|
|
101
|
+
imageMobileUrl: string | null;
|
|
102
|
+
imageDesktopUrl: string | null;
|
|
103
|
+
stackable: boolean;
|
|
104
|
+
createdAt: string;
|
|
105
|
+
updatedAt: string;
|
|
106
|
+
} | null>;
|
|
107
|
+
};
|
|
108
|
+
//# sourceMappingURL=storefront-offers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storefront-offers.d.ts","sourceRoot":"","sources":["../src/storefront-offers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAqC,6BAA6B,EAAE,MAAM,iBAAiB,CAAA;AAElG,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;iBAExC,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;iBAkB3C,CAAA;AAEF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AACnF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAyFzF,wBAAsB,+BAA+B,CACnD,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE;IACL,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,IAAI,CAAA;CACX,GACA,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAiFvC;AAED,wBAAsB,mCAAmC,CACvD,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE;IACL,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,IAAI,CAAA;CACX,GACA,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAuD5C;AAED,wBAAgB,yCAAyC,CAAC,EAAE,EAAE,kBAAkB;gCAEhD;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;0BAGlE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;;;;EAI1D"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { desc, eq, inArray } from "drizzle-orm";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { offerItems, offers } from "./schema.js";
|
|
4
|
+
import { storefrontOfferDiscountTypeSchema, storefrontOfferMetadataSchema } from "./validation.js";
|
|
5
|
+
export const storefrontOfferEnvelopeSchema = z.object({
|
|
6
|
+
storefrontPromotionalOffer: storefrontOfferMetadataSchema,
|
|
7
|
+
});
|
|
8
|
+
export const storefrontPromotionalOfferSchema = z.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
name: z.string(),
|
|
11
|
+
slug: z.string().nullable(),
|
|
12
|
+
description: z.string().nullable(),
|
|
13
|
+
discountType: storefrontOfferDiscountTypeSchema,
|
|
14
|
+
discountValue: z.string(),
|
|
15
|
+
currency: z.string().nullable(),
|
|
16
|
+
applicableProductIds: z.array(z.string()),
|
|
17
|
+
applicableDepartureIds: z.array(z.string()),
|
|
18
|
+
validFrom: z.string().nullable(),
|
|
19
|
+
validTo: z.string().nullable(),
|
|
20
|
+
minPassengers: z.number().int().nullable(),
|
|
21
|
+
imageMobileUrl: z.string().nullable(),
|
|
22
|
+
imageDesktopUrl: z.string().nullable(),
|
|
23
|
+
stackable: z.boolean(),
|
|
24
|
+
createdAt: z.string(),
|
|
25
|
+
updatedAt: z.string(),
|
|
26
|
+
});
|
|
27
|
+
function parseStorefrontMetadata(metadata) {
|
|
28
|
+
if (!metadata) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const nested = storefrontOfferEnvelopeSchema.safeParse(metadata);
|
|
32
|
+
if (nested.success) {
|
|
33
|
+
return nested.data.storefrontPromotionalOffer;
|
|
34
|
+
}
|
|
35
|
+
const direct = storefrontOfferMetadataSchema.safeParse(metadata);
|
|
36
|
+
if (direct.success) {
|
|
37
|
+
return direct.data;
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
function normalizeDateToIso(value, mode = "start") {
|
|
42
|
+
if (!value) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
if (value instanceof Date) {
|
|
46
|
+
return value.toISOString();
|
|
47
|
+
}
|
|
48
|
+
const trimmed = value.trim();
|
|
49
|
+
if (!trimmed) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(trimmed)) {
|
|
53
|
+
return new Date(`${trimmed}T${mode === "end" ? "23:59:59.999" : "00:00:00.000"}Z`).toISOString();
|
|
54
|
+
}
|
|
55
|
+
const parsed = new Date(trimmed);
|
|
56
|
+
return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
|
|
57
|
+
}
|
|
58
|
+
function isOfferActive(now, validFrom, validTo) {
|
|
59
|
+
const from = validFrom ? new Date(validFrom) : null;
|
|
60
|
+
const to = validTo ? new Date(validTo) : null;
|
|
61
|
+
if (from && from > now) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
if (to && to < now) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
function matchesLocale(metadata, locale) {
|
|
70
|
+
if (!locale || !metadata.locale) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return metadata.locale.toLowerCase() === locale.toLowerCase();
|
|
74
|
+
}
|
|
75
|
+
function matchesApplicability(input) {
|
|
76
|
+
if (!input.applicableProductIds.includes(input.productId)) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (!input.departureId) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (input.applicableDepartureIds.length === 0) {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return input.applicableDepartureIds.includes(input.departureId);
|
|
86
|
+
}
|
|
87
|
+
export async function listStorefrontPromotionalOffers(db, input) {
|
|
88
|
+
const now = input.now ?? new Date();
|
|
89
|
+
const rows = await db
|
|
90
|
+
.select()
|
|
91
|
+
.from(offers)
|
|
92
|
+
.where(eq(offers.status, "published"))
|
|
93
|
+
.orderBy(desc(offers.createdAt));
|
|
94
|
+
if (rows.length === 0) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
const offerIds = rows.map((row) => row.id);
|
|
98
|
+
const itemRows = await db
|
|
99
|
+
.select({ offerId: offerItems.offerId, productId: offerItems.productId })
|
|
100
|
+
.from(offerItems)
|
|
101
|
+
.where(inArray(offerItems.offerId, offerIds));
|
|
102
|
+
const productIdsByOffer = new Map();
|
|
103
|
+
for (const item of itemRows) {
|
|
104
|
+
if (!item.productId) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
let set = productIdsByOffer.get(item.offerId);
|
|
108
|
+
if (!set) {
|
|
109
|
+
set = new Set();
|
|
110
|
+
productIdsByOffer.set(item.offerId, set);
|
|
111
|
+
}
|
|
112
|
+
set.add(item.productId);
|
|
113
|
+
}
|
|
114
|
+
return rows
|
|
115
|
+
.map((row) => {
|
|
116
|
+
const metadata = parseStorefrontMetadata(row.metadata);
|
|
117
|
+
if (!metadata?.enabled || !matchesLocale(metadata, input.locale)) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
const validFrom = normalizeDateToIso(metadata.validFrom ?? row.validFrom, "start");
|
|
121
|
+
const validTo = normalizeDateToIso(metadata.validTo ?? row.validUntil, "end");
|
|
122
|
+
if (!isOfferActive(now, validFrom, validTo)) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const applicableProductIds = metadata.applicableProductIds.length
|
|
126
|
+
? metadata.applicableProductIds
|
|
127
|
+
: Array.from(productIdsByOffer.get(row.id) ?? []);
|
|
128
|
+
if (!matchesApplicability({
|
|
129
|
+
productId: input.productId,
|
|
130
|
+
departureId: input.departureId,
|
|
131
|
+
applicableProductIds,
|
|
132
|
+
applicableDepartureIds: metadata.applicableDepartureIds,
|
|
133
|
+
})) {
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
return storefrontPromotionalOfferSchema.parse({
|
|
137
|
+
id: row.id,
|
|
138
|
+
name: row.title,
|
|
139
|
+
slug: metadata.slug ?? null,
|
|
140
|
+
description: metadata.description ?? null,
|
|
141
|
+
discountType: metadata.discountType,
|
|
142
|
+
discountValue: metadata.discountValue,
|
|
143
|
+
currency: metadata.currency ?? row.currency ?? null,
|
|
144
|
+
applicableProductIds,
|
|
145
|
+
applicableDepartureIds: metadata.applicableDepartureIds,
|
|
146
|
+
validFrom,
|
|
147
|
+
validTo,
|
|
148
|
+
minPassengers: metadata.minPassengers ?? null,
|
|
149
|
+
imageMobileUrl: metadata.imageMobileUrl ?? null,
|
|
150
|
+
imageDesktopUrl: metadata.imageDesktopUrl ?? null,
|
|
151
|
+
stackable: metadata.stackable,
|
|
152
|
+
createdAt: row.createdAt.toISOString(),
|
|
153
|
+
updatedAt: row.updatedAt.toISOString(),
|
|
154
|
+
});
|
|
155
|
+
})
|
|
156
|
+
.filter((row) => row !== null);
|
|
157
|
+
}
|
|
158
|
+
export async function getStorefrontPromotionalOfferBySlug(db, input) {
|
|
159
|
+
const now = input.now ?? new Date();
|
|
160
|
+
const rows = await db
|
|
161
|
+
.select()
|
|
162
|
+
.from(offers)
|
|
163
|
+
.where(eq(offers.status, "published"))
|
|
164
|
+
.orderBy(desc(offers.createdAt));
|
|
165
|
+
for (const row of rows) {
|
|
166
|
+
const metadata = parseStorefrontMetadata(row.metadata);
|
|
167
|
+
if (!metadata?.enabled || !metadata.slug || !matchesLocale(metadata, input.locale)) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (metadata.slug !== input.slug) {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const validFrom = normalizeDateToIso(metadata.validFrom ?? row.validFrom, "start");
|
|
174
|
+
const validTo = normalizeDateToIso(metadata.validTo ?? row.validUntil, "end");
|
|
175
|
+
if (!isOfferActive(now, validFrom, validTo)) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const productIds = await db
|
|
179
|
+
.select({ productId: offerItems.productId })
|
|
180
|
+
.from(offerItems)
|
|
181
|
+
.where(eq(offerItems.offerId, row.id));
|
|
182
|
+
const applicableProductIds = metadata.applicableProductIds.length
|
|
183
|
+
? metadata.applicableProductIds
|
|
184
|
+
: productIds.map((item) => item.productId).filter((item) => Boolean(item));
|
|
185
|
+
return storefrontPromotionalOfferSchema.parse({
|
|
186
|
+
id: row.id,
|
|
187
|
+
name: row.title,
|
|
188
|
+
slug: metadata.slug,
|
|
189
|
+
description: metadata.description ?? null,
|
|
190
|
+
discountType: metadata.discountType,
|
|
191
|
+
discountValue: metadata.discountValue,
|
|
192
|
+
currency: metadata.currency ?? row.currency ?? null,
|
|
193
|
+
applicableProductIds,
|
|
194
|
+
applicableDepartureIds: metadata.applicableDepartureIds,
|
|
195
|
+
validFrom,
|
|
196
|
+
validTo,
|
|
197
|
+
minPassengers: metadata.minPassengers ?? null,
|
|
198
|
+
imageMobileUrl: metadata.imageMobileUrl ?? null,
|
|
199
|
+
imageDesktopUrl: metadata.imageDesktopUrl ?? null,
|
|
200
|
+
stackable: metadata.stackable,
|
|
201
|
+
createdAt: row.createdAt.toISOString(),
|
|
202
|
+
updatedAt: row.updatedAt.toISOString(),
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
export function createStorefrontPromotionalOffersResolver(db) {
|
|
208
|
+
return {
|
|
209
|
+
listApplicableOffers(input) {
|
|
210
|
+
return listStorefrontPromotionalOffers(db, input);
|
|
211
|
+
},
|
|
212
|
+
getOfferBySlug(input) {
|
|
213
|
+
return getStorefrontPromotionalOfferBySlug(db, input);
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
}
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,4 +1,50 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
export declare const storefrontOfferDiscountTypeSchema: z.ZodEnum<{
|
|
3
|
+
percentage: "percentage";
|
|
4
|
+
fixed_amount: "fixed_amount";
|
|
5
|
+
}>;
|
|
6
|
+
export declare const storefrontOfferMetadataSchema: z.ZodObject<{
|
|
7
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
locale: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
9
|
+
slug: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
10
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
11
|
+
discountType: z.ZodEnum<{
|
|
12
|
+
percentage: "percentage";
|
|
13
|
+
fixed_amount: "fixed_amount";
|
|
14
|
+
}>;
|
|
15
|
+
discountValue: z.ZodString;
|
|
16
|
+
currency: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
17
|
+
applicableProductIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
18
|
+
applicableDepartureIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
19
|
+
validFrom: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
20
|
+
validTo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
21
|
+
minPassengers: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
22
|
+
imageMobileUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
23
|
+
imageDesktopUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
24
|
+
stackable: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export declare const offerMetadataSchema: z.ZodObject<{
|
|
27
|
+
storefrontPromotionalOffer: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
29
|
+
locale: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
30
|
+
slug: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
31
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
32
|
+
discountType: z.ZodEnum<{
|
|
33
|
+
percentage: "percentage";
|
|
34
|
+
fixed_amount: "fixed_amount";
|
|
35
|
+
}>;
|
|
36
|
+
discountValue: z.ZodString;
|
|
37
|
+
currency: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
38
|
+
applicableProductIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
39
|
+
applicableDepartureIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
40
|
+
validFrom: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
41
|
+
validTo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
42
|
+
minPassengers: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
43
|
+
imageMobileUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
44
|
+
imageDesktopUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
45
|
+
stackable: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$catchall<z.ZodUnknown>>;
|
|
2
48
|
export declare const offerStatusSchema: z.ZodEnum<{
|
|
3
49
|
draft: "draft";
|
|
4
50
|
published: "published";
|
|
@@ -105,7 +151,28 @@ export declare const insertOfferSchema: z.ZodObject<{
|
|
|
105
151
|
acceptedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
106
152
|
convertedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
107
153
|
notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
108
|
-
metadata: z.ZodOptional<z.ZodNullable<z.
|
|
154
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
155
|
+
storefrontPromotionalOffer: z.ZodOptional<z.ZodObject<{
|
|
156
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
157
|
+
locale: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
158
|
+
slug: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
159
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
160
|
+
discountType: z.ZodEnum<{
|
|
161
|
+
percentage: "percentage";
|
|
162
|
+
fixed_amount: "fixed_amount";
|
|
163
|
+
}>;
|
|
164
|
+
discountValue: z.ZodString;
|
|
165
|
+
currency: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
166
|
+
applicableProductIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
167
|
+
applicableDepartureIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
168
|
+
validFrom: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
169
|
+
validTo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
170
|
+
minPassengers: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
171
|
+
imageMobileUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
172
|
+
imageDesktopUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
173
|
+
stackable: z.ZodDefault<z.ZodBoolean>;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
}, z.core.$catchall<z.ZodUnknown>>>>;
|
|
109
176
|
}, z.core.$strip>;
|
|
110
177
|
export declare const updateOfferSchema: z.ZodObject<{
|
|
111
178
|
offerNumber: z.ZodOptional<z.ZodString>;
|
|
@@ -139,7 +206,28 @@ export declare const updateOfferSchema: z.ZodObject<{
|
|
|
139
206
|
acceptedAt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
140
207
|
convertedAt: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
141
208
|
notes: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodString>>>;
|
|
142
|
-
metadata: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.
|
|
209
|
+
metadata: z.ZodOptional<z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
210
|
+
storefrontPromotionalOffer: z.ZodOptional<z.ZodObject<{
|
|
211
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
212
|
+
locale: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
213
|
+
slug: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
214
|
+
description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
215
|
+
discountType: z.ZodEnum<{
|
|
216
|
+
percentage: "percentage";
|
|
217
|
+
fixed_amount: "fixed_amount";
|
|
218
|
+
}>;
|
|
219
|
+
discountValue: z.ZodString;
|
|
220
|
+
currency: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
221
|
+
applicableProductIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
222
|
+
applicableDepartureIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
223
|
+
validFrom: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
224
|
+
validTo: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
225
|
+
minPassengers: z.ZodNullable<z.ZodOptional<z.ZodNumber>>;
|
|
226
|
+
imageMobileUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
227
|
+
imageDesktopUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
228
|
+
stackable: z.ZodDefault<z.ZodBoolean>;
|
|
229
|
+
}, z.core.$strip>>;
|
|
230
|
+
}, z.core.$catchall<z.ZodUnknown>>>>>;
|
|
143
231
|
}, z.core.$strip>;
|
|
144
232
|
export declare const offerListQuerySchema: z.ZodObject<{
|
|
145
233
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
package/dist/validation.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB,eAAO,MAAM,iCAAiC;;;EAAyC,CAAA;AAEvF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;iBAgBxC,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;kCAIR,CAAA;AAExB,eAAO,MAAM,iBAAiB;;;;;;;;EAQ5B,CAAA;AAEF,eAAO,MAAM,iBA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAkB,CAAA;AAChD,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA4B,CAAA;AAC1D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;iBAS/B,CAAA;AAEF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEvC,CAAA;AACF,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAkC,CAAA;AAC3E,eAAO,MAAM,+BAA+B;;;;;iBAG1C,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEhC,CAAA;AACF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgC,CAAA;AAClE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;iBAQnC,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;iBAE3C,CAAA;AACF,eAAO,MAAM,gCAAgC;;;;;;;;;;;iBAAsC,CAAA;AACnF,eAAO,MAAM,mCAAmC;;;;;iBAG9C,CAAA;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgC,CAAA;AAClE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgC,CAAA;AAClE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;iBAKnC,CAAA"}
|
package/dist/validation.js
CHANGED
|
@@ -4,6 +4,30 @@ const paginationSchema = z.object({
|
|
|
4
4
|
offset: z.coerce.number().int().min(0).default(0),
|
|
5
5
|
});
|
|
6
6
|
const moneySchema = z.number().int().nullable().optional();
|
|
7
|
+
const metadataRecordSchema = z.record(z.string(), z.unknown());
|
|
8
|
+
export const storefrontOfferDiscountTypeSchema = z.enum(["percentage", "fixed_amount"]);
|
|
9
|
+
export const storefrontOfferMetadataSchema = z.object({
|
|
10
|
+
enabled: z.boolean().default(true),
|
|
11
|
+
locale: z.string().trim().min(2).optional().nullable(),
|
|
12
|
+
slug: z.string().trim().min(1).optional().nullable(),
|
|
13
|
+
description: z.string().trim().min(1).optional().nullable(),
|
|
14
|
+
discountType: storefrontOfferDiscountTypeSchema,
|
|
15
|
+
discountValue: z.string().trim().min(1),
|
|
16
|
+
currency: z.string().trim().length(3).optional().nullable(),
|
|
17
|
+
applicableProductIds: z.array(z.string()).default([]),
|
|
18
|
+
applicableDepartureIds: z.array(z.string()).default([]),
|
|
19
|
+
validFrom: z.string().optional().nullable(),
|
|
20
|
+
validTo: z.string().optional().nullable(),
|
|
21
|
+
minPassengers: z.number().int().min(1).optional().nullable(),
|
|
22
|
+
imageMobileUrl: z.string().trim().min(1).optional().nullable(),
|
|
23
|
+
imageDesktopUrl: z.string().trim().min(1).optional().nullable(),
|
|
24
|
+
stackable: z.boolean().default(false),
|
|
25
|
+
});
|
|
26
|
+
export const offerMetadataSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
storefrontPromotionalOffer: storefrontOfferMetadataSchema.optional(),
|
|
29
|
+
})
|
|
30
|
+
.catchall(z.unknown());
|
|
7
31
|
export const offerStatusSchema = z.enum([
|
|
8
32
|
"draft",
|
|
9
33
|
"published",
|
|
@@ -102,7 +126,7 @@ const offerCoreSchema = z.object({
|
|
|
102
126
|
acceptedAt: z.string().nullable().optional(),
|
|
103
127
|
convertedAt: z.string().nullable().optional(),
|
|
104
128
|
notes: z.string().nullable().optional(),
|
|
105
|
-
metadata:
|
|
129
|
+
metadata: offerMetadataSchema.nullable().optional(),
|
|
106
130
|
});
|
|
107
131
|
const participantCoreSchema = z.object({
|
|
108
132
|
personId: z.string().nullable().optional(),
|
|
@@ -188,7 +212,7 @@ const orderTermCoreSchema = z.object({
|
|
|
188
212
|
acceptanceStatus: orderTermAcceptanceStatusSchema.default("pending"),
|
|
189
213
|
acceptedAt: z.string().nullable().optional(),
|
|
190
214
|
acceptedBy: z.string().max(255).nullable().optional(),
|
|
191
|
-
metadata:
|
|
215
|
+
metadata: metadataRecordSchema.nullable().optional(),
|
|
192
216
|
});
|
|
193
217
|
const orderTermRequiredParentSchema = orderTermCoreSchema.refine((value) => Boolean(value.offerId || value.orderId), {
|
|
194
218
|
message: "offerId or orderId is required",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/transactions",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "FSL-1.1-Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"drizzle-orm": "^0.45.2",
|
|
30
30
|
"hono": "^4.12.10",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@voyantjs/core": "0.
|
|
33
|
-
"@voyantjs/db": "0.
|
|
34
|
-
"@voyantjs/hono": "0.
|
|
35
|
-
"@voyantjs/utils": "0.
|
|
32
|
+
"@voyantjs/core": "0.4.0",
|
|
33
|
+
"@voyantjs/db": "0.4.0",
|
|
34
|
+
"@voyantjs/hono": "0.4.0",
|
|
35
|
+
"@voyantjs/utils": "0.4.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "^6.0.2",
|