@voyantjs/storefront 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/service.d.ts CHANGED
@@ -1,9 +1,204 @@
1
- import { type StorefrontSettings, type StorefrontSettingsInput } from "./validation.js";
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import { type StorefrontDepartureListQuery, type StorefrontDeparturePricePreviewInput, type StorefrontPromotionalOffer, type StorefrontSettings, type StorefrontSettingsInput } from "./validation.js";
2
3
  export interface StorefrontServiceOptions {
3
4
  settings?: StorefrontSettingsInput;
5
+ offers?: {
6
+ listApplicableOffers?: (input: {
7
+ productId: string;
8
+ departureId?: string;
9
+ locale?: string;
10
+ }) => Promise<StorefrontPromotionalOffer[]> | StorefrontPromotionalOffer[];
11
+ getOfferBySlug?: (input: {
12
+ slug: string;
13
+ locale?: string;
14
+ }) => Promise<StorefrontPromotionalOffer | null> | StorefrontPromotionalOffer | null;
15
+ };
4
16
  }
5
17
  export declare function resolveStorefrontSettings(input?: StorefrontSettingsInput): StorefrontSettings;
6
18
  export declare function createStorefrontService(options?: StorefrontServiceOptions): {
7
19
  getSettings(): StorefrontSettings;
20
+ getDeparture(db: PostgresJsDatabase, departureId: string): Promise<{
21
+ id: string;
22
+ productId: string;
23
+ itineraryId: string;
24
+ optionId: string | null;
25
+ dateLocal: string | null;
26
+ startAt: string | null;
27
+ endAt: string | null;
28
+ timezone: string;
29
+ startTime: {
30
+ id: string;
31
+ label: string | null;
32
+ startTimeLocal: string;
33
+ durationMinutes: number | null;
34
+ } | null;
35
+ meetingPoint: string | null;
36
+ capacity: number | null;
37
+ remaining: number | null;
38
+ departureStatus: "open" | "closed" | "sold_out" | "cancelled" | "on_request";
39
+ nights: number | null;
40
+ days: number | null;
41
+ ratePlans: {
42
+ id: string;
43
+ active: boolean;
44
+ name: string;
45
+ pricingModel: string;
46
+ basePrices: {
47
+ amount: number;
48
+ currencyCode: string;
49
+ }[];
50
+ roomPrices: {
51
+ amount: number;
52
+ currencyCode: string;
53
+ roomType: {
54
+ id: string;
55
+ name: string;
56
+ occupancy: {
57
+ adultsMin: number;
58
+ adultsMax: number;
59
+ childrenMax: number;
60
+ };
61
+ };
62
+ }[];
63
+ }[];
64
+ } | null>;
65
+ listProductDepartures(db: PostgresJsDatabase, productId: string, query: StorefrontDepartureListQuery): Promise<{
66
+ data: {
67
+ id: string;
68
+ productId: string;
69
+ itineraryId: string;
70
+ optionId: string | null;
71
+ dateLocal: string | null;
72
+ startAt: string | null;
73
+ endAt: string | null;
74
+ timezone: string;
75
+ startTime: {
76
+ id: string;
77
+ label: string | null;
78
+ startTimeLocal: string;
79
+ durationMinutes: number | null;
80
+ } | null;
81
+ meetingPoint: string | null;
82
+ capacity: number | null;
83
+ remaining: number | null;
84
+ departureStatus: "open" | "closed" | "sold_out" | "cancelled" | "on_request";
85
+ nights: number | null;
86
+ days: number | null;
87
+ ratePlans: {
88
+ id: string;
89
+ active: boolean;
90
+ name: string;
91
+ pricingModel: string;
92
+ basePrices: {
93
+ amount: number;
94
+ currencyCode: string;
95
+ }[];
96
+ roomPrices: {
97
+ amount: number;
98
+ currencyCode: string;
99
+ roomType: {
100
+ id: string;
101
+ name: string;
102
+ occupancy: {
103
+ adultsMin: number;
104
+ adultsMax: number;
105
+ childrenMax: number;
106
+ };
107
+ };
108
+ }[];
109
+ }[];
110
+ }[];
111
+ total: number;
112
+ limit: number;
113
+ offset: number;
114
+ }>;
115
+ previewDeparturePrice(db: PostgresJsDatabase, departureId: string, input: StorefrontDeparturePricePreviewInput): Promise<{
116
+ departureId: string;
117
+ productId: string;
118
+ optionId: string | null;
119
+ currencyCode: string;
120
+ basePrice: number;
121
+ taxAmount: number;
122
+ total: number;
123
+ notes: string | null;
124
+ lineItems: {
125
+ name: string;
126
+ total: number;
127
+ quantity: number;
128
+ unitPrice: number;
129
+ }[];
130
+ } | null>;
131
+ getProductExtensions(db: PostgresJsDatabase, productId: string, optionId?: string): Promise<{
132
+ extensions: {
133
+ id: string;
134
+ name: string;
135
+ label: string;
136
+ required: boolean;
137
+ selectable: boolean;
138
+ hasOptions: boolean;
139
+ refProductId: string | null;
140
+ thumb: string | null;
141
+ pricePerPerson: number | null;
142
+ currencyCode: string;
143
+ pricingMode: string;
144
+ defaultQuantity: number | null;
145
+ minQuantity: number | null;
146
+ maxQuantity: number | null;
147
+ }[];
148
+ items: {
149
+ id: string;
150
+ name: string;
151
+ label: string;
152
+ required: boolean;
153
+ selectable: boolean;
154
+ hasOptions: boolean;
155
+ refProductId: string | null;
156
+ thumb: string | null;
157
+ pricePerPerson: number | null;
158
+ currencyCode: string;
159
+ pricingMode: string;
160
+ defaultQuantity: number | null;
161
+ minQuantity: number | null;
162
+ maxQuantity: number | null;
163
+ }[];
164
+ details: {
165
+ [k: string]: {
166
+ description: string | null;
167
+ media: {
168
+ url: string;
169
+ alt: string | null;
170
+ }[];
171
+ };
172
+ };
173
+ currencyCode: string;
174
+ }>;
175
+ getDepartureItinerary(db: PostgresJsDatabase, input: {
176
+ departureId: string;
177
+ productId: string;
178
+ }): Promise<{
179
+ id: string;
180
+ days: {
181
+ id: string;
182
+ title: string;
183
+ description: string | null;
184
+ thumbnail: {
185
+ url: string;
186
+ } | null;
187
+ segments: {
188
+ id: string;
189
+ title: string;
190
+ description: string | null;
191
+ }[];
192
+ }[];
193
+ } | null>;
194
+ listApplicableOffers(input: {
195
+ productId: string;
196
+ departureId?: string;
197
+ locale?: string;
198
+ }): Promise<StorefrontPromotionalOffer[]>;
199
+ getOfferBySlug(input: {
200
+ slug: string;
201
+ locale?: string;
202
+ }): Promise<StorefrontPromotionalOffer | null>;
8
203
  };
9
204
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,iBA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;;;;;;;;;;;;;;;;;;;;;;;8BAIlD,kBAAkB,aACX,MAAM,SACV,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAK/B,kBAAkB,eACT,MAAM,SACZ,oCAAoC;;;;;;;;;;;;;;;;6BAIpB,kBAAkB,aAAa,MAAM,aAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAI3E,kBAAkB,SACf;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;;;;;;;;;;;;;;;;gCAIjB;QAChC,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,GAAG,OAAO,CAAC,0BAA0B,EAAE,CAAC;0BAIb;QAC1B,IAAI,EAAE,MAAM,CAAA;QACZ,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,GAAG,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC;EAIjD"}
package/dist/service.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { getStorefrontDeparture, getStorefrontDepartureItinerary, getStorefrontProductExtensions, listStorefrontProductDepartures, previewStorefrontDeparturePrice, } from "./service-departures.js";
1
2
  import { storefrontSettingsInputSchema, storefrontSettingsSchema, } from "./validation.js";
2
3
  const defaultPaymentLabels = {
3
4
  card: "Card",
@@ -62,5 +63,27 @@ export function createStorefrontService(options) {
62
63
  getSettings() {
63
64
  return settings;
64
65
  },
66
+ getDeparture(db, departureId) {
67
+ return getStorefrontDeparture(db, departureId);
68
+ },
69
+ listProductDepartures(db, productId, query) {
70
+ return listStorefrontProductDepartures(db, productId, query);
71
+ },
72
+ previewDeparturePrice(db, departureId, input) {
73
+ return previewStorefrontDeparturePrice(db, departureId, input);
74
+ },
75
+ getProductExtensions(db, productId, optionId) {
76
+ return getStorefrontProductExtensions(db, productId, optionId);
77
+ },
78
+ getDepartureItinerary(db, input) {
79
+ return getStorefrontDepartureItinerary(db, input);
80
+ },
81
+ async listApplicableOffers(input) {
82
+ const offers = await options?.offers?.listApplicableOffers?.(input);
83
+ return offers ?? [];
84
+ },
85
+ async getOfferBySlug(input) {
86
+ return (await options?.offers?.getOfferBySlug?.(input)) ?? null;
87
+ },
65
88
  };
66
89
  }