@voyantjs/storefront 0.3.1 → 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 CHANGED
@@ -5,8 +5,8 @@ export type { StorefrontPublicRoutes } from "./routes-public.js";
5
5
  export { createStorefrontPublicRoutes } from "./routes-public.js";
6
6
  export type { StorefrontServiceOptions } from "./service.js";
7
7
  export { createStorefrontService, resolveStorefrontSettings } from "./service.js";
8
- export type { StorefrontFormField, StorefrontFormFieldInput, StorefrontPaymentMethod, StorefrontPaymentMethodCode, StorefrontPaymentMethodInput, StorefrontSettings, StorefrontSettingsInput, } from "./validation.js";
9
- export { storefrontFormFieldInputSchema, storefrontFormFieldOptionSchema, storefrontFormFieldSchema, storefrontFormFieldTypeSchema, storefrontPaymentMethodCodeSchema, storefrontPaymentMethodInputSchema, storefrontPaymentMethodSchema, storefrontSettingsInputSchema, storefrontSettingsSchema, } from "./validation.js";
8
+ export type { StorefrontDepartureListQuery, StorefrontFormField, StorefrontFormFieldInput, StorefrontPaymentMethod, StorefrontPaymentMethodCode, StorefrontPaymentMethodInput, StorefrontPromotionalOffer, StorefrontSettings, StorefrontSettingsInput, } from "./validation.js";
9
+ export { storefrontDepartureItinerarySchema, storefrontDepartureListQuerySchema, storefrontDepartureListResponseSchema, storefrontDeparturePricePreviewInputSchema, storefrontDeparturePricePreviewSchema, storefrontDepartureSchema, storefrontFormFieldInputSchema, storefrontFormFieldOptionSchema, storefrontFormFieldSchema, storefrontFormFieldTypeSchema, storefrontPaymentMethodCodeSchema, storefrontPaymentMethodInputSchema, storefrontPaymentMethodSchema, storefrontProductExtensionsQuerySchema, storefrontProductExtensionsResponseSchema, storefrontPromotionalOfferListQuerySchema, storefrontPromotionalOfferListResponseSchema, storefrontPromotionalOfferResponseSchema, storefrontPromotionalOfferSchema, storefrontSettingsInputSchema, storefrontSettingsSchema, } from "./validation.js";
10
10
  export declare const storefrontModule: Module;
11
11
  export declare function createStorefrontHonoModule(options?: Parameters<typeof createStorefrontPublicRoutes>[0]): HonoModule;
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AAEjE,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,YAAY,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACjF,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,4BAA4B,EAC5B,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,6BAA6B,EAC7B,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,iBAAiB,CAAA;AAExB,eAAO,MAAM,gBAAgB,EAAE,MAE9B,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAC,GAC3D,UAAU,CAKZ"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AAEjE,YAAY,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAA;AACjE,YAAY,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACjF,YAAY,EACV,4BAA4B,EAC5B,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EAClC,qCAAqC,EACrC,0CAA0C,EAC1C,qCAAqC,EACrC,yBAAyB,EACzB,8BAA8B,EAC9B,+BAA+B,EAC/B,yBAAyB,EACzB,6BAA6B,EAC7B,iCAAiC,EACjC,kCAAkC,EAClC,6BAA6B,EAC7B,sCAAsC,EACtC,yCAAyC,EACzC,yCAAyC,EACzC,4CAA4C,EAC5C,wCAAwC,EACxC,gCAAgC,EAChC,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,iBAAiB,CAAA;AAExB,eAAO,MAAM,gBAAgB,EAAE,MAE9B,CAAA;AAED,wBAAgB,0BAA0B,CACxC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAC,GAC3D,UAAU,CAKZ"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createStorefrontPublicRoutes } from "./routes-public.js";
2
2
  export { createStorefrontPublicRoutes } from "./routes-public.js";
3
3
  export { createStorefrontService, resolveStorefrontSettings } from "./service.js";
4
- export { storefrontFormFieldInputSchema, storefrontFormFieldOptionSchema, storefrontFormFieldSchema, storefrontFormFieldTypeSchema, storefrontPaymentMethodCodeSchema, storefrontPaymentMethodInputSchema, storefrontPaymentMethodSchema, storefrontSettingsInputSchema, storefrontSettingsSchema, } from "./validation.js";
4
+ export { storefrontDepartureItinerarySchema, storefrontDepartureListQuerySchema, storefrontDepartureListResponseSchema, storefrontDeparturePricePreviewInputSchema, storefrontDeparturePricePreviewSchema, storefrontDepartureSchema, storefrontFormFieldInputSchema, storefrontFormFieldOptionSchema, storefrontFormFieldSchema, storefrontFormFieldTypeSchema, storefrontPaymentMethodCodeSchema, storefrontPaymentMethodInputSchema, storefrontPaymentMethodSchema, storefrontProductExtensionsQuerySchema, storefrontProductExtensionsResponseSchema, storefrontPromotionalOfferListQuerySchema, storefrontPromotionalOfferListResponseSchema, storefrontPromotionalOfferResponseSchema, storefrontPromotionalOfferSchema, storefrontSettingsInputSchema, storefrontSettingsSchema, } from "./validation.js";
5
5
  export const storefrontModule = {
6
6
  name: "storefront",
7
7
  };
@@ -1,5 +1,10 @@
1
1
  import { type StorefrontServiceOptions } from "./service.js";
2
- export declare function createStorefrontPublicRoutes(options?: StorefrontServiceOptions): import("hono/hono-base").HonoBase<import("hono/types").BlankEnv, {
2
+ type Env = {
3
+ Variables: {
4
+ db: unknown;
5
+ };
6
+ };
7
+ export declare function createStorefrontPublicRoutes(options?: StorefrontServiceOptions): import("hono/hono-base").HonoBase<Env, {
3
8
  "/settings": {
4
9
  $get: {
5
10
  input: {};
@@ -23,7 +28,7 @@ export declare function createStorefrontPublicRoutes(options?: StorefrontService
23
28
  fields: {
24
29
  key: string;
25
30
  label: string;
26
- type: "text" | "email" | "tel" | "textarea" | "select" | "checkbox" | "date" | "country";
31
+ type: "date" | "select" | "email" | "country" | "text" | "tel" | "textarea" | "checkbox";
27
32
  required: boolean;
28
33
  placeholder: string | null;
29
34
  description: string | null;
@@ -38,7 +43,7 @@ export declare function createStorefrontPublicRoutes(options?: StorefrontService
38
43
  fields: {
39
44
  key: string;
40
45
  label: string;
41
- type: "text" | "email" | "tel" | "textarea" | "select" | "checkbox" | "date" | "country";
46
+ type: "date" | "select" | "email" | "country" | "text" | "tel" | "textarea" | "checkbox";
42
47
  required: boolean;
43
48
  placeholder: string | null;
44
49
  description: string | null;
@@ -51,9 +56,9 @@ export declare function createStorefrontPublicRoutes(options?: StorefrontService
51
56
  };
52
57
  };
53
58
  payment: {
54
- defaultMethod: "card" | "bank_transfer" | "cash" | "voucher" | "invoice" | null;
59
+ defaultMethod: "voucher" | "card" | "bank_transfer" | "cash" | "invoice" | null;
55
60
  methods: {
56
- code: "card" | "bank_transfer" | "cash" | "voucher" | "invoice";
61
+ code: "voucher" | "card" | "bank_transfer" | "cash" | "invoice";
57
62
  label: string;
58
63
  description: string | null;
59
64
  enabled: boolean;
@@ -65,6 +70,360 @@ export declare function createStorefrontPublicRoutes(options?: StorefrontService
65
70
  status: import("hono/utils/http-status").ContentfulStatusCode;
66
71
  };
67
72
  };
68
- }, "/", "/settings">;
73
+ } & {
74
+ "/departures/:departureId": {
75
+ $get: {
76
+ input: {
77
+ param: {
78
+ departureId: string;
79
+ };
80
+ };
81
+ output: {
82
+ data: {
83
+ id: string;
84
+ productId: string;
85
+ itineraryId: string;
86
+ optionId: string | null;
87
+ dateLocal: string | null;
88
+ startAt: string | null;
89
+ endAt: string | null;
90
+ timezone: string;
91
+ startTime: {
92
+ id: string;
93
+ label: string | null;
94
+ startTimeLocal: string;
95
+ durationMinutes: number | null;
96
+ } | null;
97
+ meetingPoint: string | null;
98
+ capacity: number | null;
99
+ remaining: number | null;
100
+ departureStatus: "open" | "closed" | "sold_out" | "cancelled" | "on_request";
101
+ nights: number | null;
102
+ days: number | null;
103
+ ratePlans: {
104
+ id: string;
105
+ active: boolean;
106
+ name: string;
107
+ pricingModel: string;
108
+ basePrices: {
109
+ amount: number;
110
+ currencyCode: string;
111
+ }[];
112
+ roomPrices: {
113
+ amount: number;
114
+ currencyCode: string;
115
+ roomType: {
116
+ id: string;
117
+ name: string;
118
+ occupancy: {
119
+ adultsMin: number;
120
+ adultsMax: number;
121
+ childrenMax: number;
122
+ };
123
+ };
124
+ }[];
125
+ }[];
126
+ };
127
+ };
128
+ outputFormat: "json";
129
+ status: import("hono/utils/http-status").ContentfulStatusCode;
130
+ } | {
131
+ input: {
132
+ param: {
133
+ departureId: string;
134
+ };
135
+ };
136
+ output: {
137
+ error: string;
138
+ };
139
+ outputFormat: "json";
140
+ status: 404;
141
+ };
142
+ };
143
+ } & {
144
+ "/products/:productId/departures": {
145
+ $get: {
146
+ input: {
147
+ param: {
148
+ productId: string;
149
+ };
150
+ };
151
+ output: {
152
+ data: {
153
+ id: string;
154
+ productId: string;
155
+ itineraryId: string;
156
+ optionId: string | null;
157
+ dateLocal: string | null;
158
+ startAt: string | null;
159
+ endAt: string | null;
160
+ timezone: string;
161
+ startTime: {
162
+ id: string;
163
+ label: string | null;
164
+ startTimeLocal: string;
165
+ durationMinutes: number | null;
166
+ } | null;
167
+ meetingPoint: string | null;
168
+ capacity: number | null;
169
+ remaining: number | null;
170
+ departureStatus: "open" | "closed" | "sold_out" | "cancelled" | "on_request";
171
+ nights: number | null;
172
+ days: number | null;
173
+ ratePlans: {
174
+ id: string;
175
+ active: boolean;
176
+ name: string;
177
+ pricingModel: string;
178
+ basePrices: {
179
+ amount: number;
180
+ currencyCode: string;
181
+ }[];
182
+ roomPrices: {
183
+ amount: number;
184
+ currencyCode: string;
185
+ roomType: {
186
+ id: string;
187
+ name: string;
188
+ occupancy: {
189
+ adultsMin: number;
190
+ adultsMax: number;
191
+ childrenMax: number;
192
+ };
193
+ };
194
+ }[];
195
+ }[];
196
+ }[];
197
+ total: number;
198
+ limit: number;
199
+ offset: number;
200
+ };
201
+ outputFormat: "json";
202
+ status: import("hono/utils/http-status").ContentfulStatusCode;
203
+ };
204
+ };
205
+ } & {
206
+ "/departures/:departureId/price": {
207
+ $post: {
208
+ input: {
209
+ param: {
210
+ departureId: string;
211
+ };
212
+ };
213
+ output: {
214
+ data: {
215
+ departureId: string;
216
+ productId: string;
217
+ optionId: string | null;
218
+ currencyCode: string;
219
+ basePrice: number;
220
+ taxAmount: number;
221
+ total: number;
222
+ notes: string | null;
223
+ lineItems: {
224
+ name: string;
225
+ total: number;
226
+ quantity: number;
227
+ unitPrice: number;
228
+ }[];
229
+ };
230
+ };
231
+ outputFormat: "json";
232
+ status: import("hono/utils/http-status").ContentfulStatusCode;
233
+ } | {
234
+ input: {
235
+ param: {
236
+ departureId: string;
237
+ };
238
+ };
239
+ output: {
240
+ error: string;
241
+ };
242
+ outputFormat: "json";
243
+ status: 404;
244
+ };
245
+ };
246
+ } & {
247
+ "/products/:productId/extensions": {
248
+ $get: {
249
+ input: {
250
+ param: {
251
+ productId: string;
252
+ };
253
+ };
254
+ output: {
255
+ data: {
256
+ extensions: {
257
+ id: string;
258
+ name: string;
259
+ label: string;
260
+ required: boolean;
261
+ selectable: boolean;
262
+ hasOptions: boolean;
263
+ refProductId: string | null;
264
+ thumb: string | null;
265
+ pricePerPerson: number | null;
266
+ currencyCode: string;
267
+ pricingMode: string;
268
+ defaultQuantity: number | null;
269
+ minQuantity: number | null;
270
+ maxQuantity: number | null;
271
+ }[];
272
+ items: {
273
+ id: string;
274
+ name: string;
275
+ label: string;
276
+ required: boolean;
277
+ selectable: boolean;
278
+ hasOptions: boolean;
279
+ refProductId: string | null;
280
+ thumb: string | null;
281
+ pricePerPerson: number | null;
282
+ currencyCode: string;
283
+ pricingMode: string;
284
+ defaultQuantity: number | null;
285
+ minQuantity: number | null;
286
+ maxQuantity: number | null;
287
+ }[];
288
+ details: {
289
+ [x: string]: {
290
+ description: string | null;
291
+ media: {
292
+ url: string;
293
+ alt: string | null;
294
+ }[];
295
+ };
296
+ };
297
+ currencyCode: string;
298
+ };
299
+ };
300
+ outputFormat: "json";
301
+ status: import("hono/utils/http-status").ContentfulStatusCode;
302
+ };
303
+ };
304
+ } & {
305
+ "/products/:productId/departures/:departureId/itinerary": {
306
+ $get: {
307
+ input: {
308
+ param: {
309
+ departureId: string;
310
+ } & {
311
+ productId: string;
312
+ };
313
+ };
314
+ output: {
315
+ data: {
316
+ id: string;
317
+ days: {
318
+ id: string;
319
+ title: string;
320
+ description: string | null;
321
+ thumbnail: {
322
+ url: string;
323
+ } | null;
324
+ segments: {
325
+ id: string;
326
+ title: string;
327
+ description: string | null;
328
+ }[];
329
+ }[];
330
+ };
331
+ };
332
+ outputFormat: "json";
333
+ status: import("hono/utils/http-status").ContentfulStatusCode;
334
+ } | {
335
+ input: {
336
+ param: {
337
+ departureId: string;
338
+ } & {
339
+ productId: string;
340
+ };
341
+ };
342
+ output: {
343
+ error: string;
344
+ };
345
+ outputFormat: "json";
346
+ status: 404;
347
+ };
348
+ };
349
+ } & {
350
+ "/products/:productId/offers": {
351
+ $get: {
352
+ input: {
353
+ param: {
354
+ productId: string;
355
+ };
356
+ };
357
+ output: {
358
+ data: {
359
+ id: string;
360
+ name: string;
361
+ slug: string | null;
362
+ description: string | null;
363
+ discountType: "percentage" | "fixed_amount";
364
+ discountValue: string;
365
+ currency: string | null;
366
+ applicableProductIds: string[];
367
+ applicableDepartureIds: string[];
368
+ validFrom: string | null;
369
+ validTo: string | null;
370
+ minPassengers: number | null;
371
+ imageMobileUrl: string | null;
372
+ imageDesktopUrl: string | null;
373
+ stackable: boolean;
374
+ createdAt: string;
375
+ updatedAt: string;
376
+ }[];
377
+ };
378
+ outputFormat: "json";
379
+ status: import("hono/utils/http-status").ContentfulStatusCode;
380
+ };
381
+ };
382
+ } & {
383
+ "/offers/:slug": {
384
+ $get: {
385
+ input: {
386
+ param: {
387
+ slug: string;
388
+ };
389
+ };
390
+ output: {
391
+ data: {
392
+ id: string;
393
+ name: string;
394
+ slug: string | null;
395
+ description: string | null;
396
+ discountType: "percentage" | "fixed_amount";
397
+ discountValue: string;
398
+ currency: string | null;
399
+ applicableProductIds: string[];
400
+ applicableDepartureIds: string[];
401
+ validFrom: string | null;
402
+ validTo: string | null;
403
+ minPassengers: number | null;
404
+ imageMobileUrl: string | null;
405
+ imageDesktopUrl: string | null;
406
+ stackable: boolean;
407
+ createdAt: string;
408
+ updatedAt: string;
409
+ };
410
+ };
411
+ outputFormat: "json";
412
+ status: import("hono/utils/http-status").ContentfulStatusCode;
413
+ } | {
414
+ input: {
415
+ param: {
416
+ slug: string;
417
+ };
418
+ };
419
+ output: {
420
+ error: string;
421
+ };
422
+ outputFormat: "json";
423
+ status: 404;
424
+ };
425
+ };
426
+ }, "/", "/offers/:slug">;
69
427
  export type StorefrontPublicRoutes = ReturnType<typeof createStorefrontPublicRoutes>;
428
+ export {};
70
429
  //# sourceMappingURL=routes-public.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"routes-public.d.ts","sourceRoot":"","sources":["../src/routes-public.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAErF,wBAAgB,4BAA4B,CAAC,OAAO,CAAC,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAM9E;AAED,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAA"}
1
+ {"version":3,"file":"routes-public.d.ts","sourceRoot":"","sources":["../src/routes-public.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAQrF,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,OAAO,CAAA;KACZ,CAAA;CACF,CAAA;AAED,wBAAgB,4BAA4B,CAAC,OAAO,CAAC,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAoF9E;AAED,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAA"}
@@ -1,8 +1,57 @@
1
1
  import { Hono } from "hono";
2
2
  import { createStorefrontService } from "./service.js";
3
+ import { storefrontDepartureListQuerySchema, storefrontDeparturePricePreviewInputSchema, storefrontProductExtensionsQuerySchema, storefrontPromotionalOfferListQuerySchema, } from "./validation.js";
3
4
  export function createStorefrontPublicRoutes(options) {
4
5
  const storefrontService = createStorefrontService(options);
5
- return new Hono().get("/settings", (c) => {
6
+ return new Hono()
7
+ .get("/settings", (c) => {
6
8
  return c.json({ data: storefrontService.getSettings() });
9
+ })
10
+ .get("/departures/:departureId", async (c) => {
11
+ const departure = await storefrontService.getDeparture(c.get("db"), c.req.param("departureId"));
12
+ return departure
13
+ ? c.json({ data: departure })
14
+ : c.json({ error: "Storefront departure not found" }, 404);
15
+ })
16
+ .get("/products/:productId/departures", async (c) => {
17
+ return c.json(await storefrontService.listProductDepartures(c.get("db"), c.req.param("productId"), storefrontDepartureListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams))));
18
+ })
19
+ .post("/departures/:departureId/price", async (c) => {
20
+ const preview = await storefrontService.previewDeparturePrice(c.get("db"), c.req.param("departureId"), storefrontDeparturePricePreviewInputSchema.parse(await c.req.json().catch(() => ({}))));
21
+ return preview
22
+ ? c.json({ data: preview })
23
+ : c.json({ error: "Storefront departure not found" }, 404);
24
+ })
25
+ .get("/products/:productId/extensions", async (c) => {
26
+ return c.json({
27
+ data: await storefrontService.getProductExtensions(c.get("db"), c.req.param("productId"), storefrontProductExtensionsQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams)).optionId),
28
+ });
29
+ })
30
+ .get("/products/:productId/departures/:departureId/itinerary", async (c) => {
31
+ const itinerary = await storefrontService.getDepartureItinerary(c.get("db"), {
32
+ departureId: c.req.param("departureId"),
33
+ productId: c.req.param("productId"),
34
+ });
35
+ return itinerary
36
+ ? c.json({ data: itinerary })
37
+ : c.json({ error: "Storefront itinerary not found" }, 404);
38
+ })
39
+ .get("/products/:productId/offers", async (c) => {
40
+ const query = storefrontPromotionalOfferListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
41
+ return c.json({
42
+ data: await storefrontService.listApplicableOffers({
43
+ productId: c.req.param("productId"),
44
+ departureId: query.departureId,
45
+ locale: query.locale,
46
+ }),
47
+ });
48
+ })
49
+ .get("/offers/:slug", async (c) => {
50
+ const query = storefrontPromotionalOfferListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
51
+ const offer = await storefrontService.getOfferBySlug({
52
+ slug: c.req.param("slug"),
53
+ locale: query.locale,
54
+ });
55
+ return offer ? c.json({ data: offer }) : c.json({ error: "Storefront offer not found" }, 404);
7
56
  });
8
57
  }
@@ -0,0 +1,177 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { StorefrontDepartureListQuery, StorefrontDeparturePricePreviewInput } from "./validation.js";
3
+ export declare function getStorefrontDeparture(db: PostgresJsDatabase, departureId: string): Promise<{
4
+ id: string;
5
+ productId: string;
6
+ itineraryId: string;
7
+ optionId: string | null;
8
+ dateLocal: string | null;
9
+ startAt: string | null;
10
+ endAt: string | null;
11
+ timezone: string;
12
+ startTime: {
13
+ id: string;
14
+ label: string | null;
15
+ startTimeLocal: string;
16
+ durationMinutes: number | null;
17
+ } | null;
18
+ meetingPoint: string | null;
19
+ capacity: number | null;
20
+ remaining: number | null;
21
+ departureStatus: "open" | "closed" | "sold_out" | "cancelled" | "on_request";
22
+ nights: number | null;
23
+ days: number | null;
24
+ ratePlans: {
25
+ id: string;
26
+ active: boolean;
27
+ name: string;
28
+ pricingModel: string;
29
+ basePrices: {
30
+ amount: number;
31
+ currencyCode: string;
32
+ }[];
33
+ roomPrices: {
34
+ amount: number;
35
+ currencyCode: string;
36
+ roomType: {
37
+ id: string;
38
+ name: string;
39
+ occupancy: {
40
+ adultsMin: number;
41
+ adultsMax: number;
42
+ childrenMax: number;
43
+ };
44
+ };
45
+ }[];
46
+ }[];
47
+ } | null>;
48
+ export declare function listStorefrontProductDepartures(db: PostgresJsDatabase, productId: string, query: StorefrontDepartureListQuery): Promise<{
49
+ data: {
50
+ id: string;
51
+ productId: string;
52
+ itineraryId: string;
53
+ optionId: string | null;
54
+ dateLocal: string | null;
55
+ startAt: string | null;
56
+ endAt: string | null;
57
+ timezone: string;
58
+ startTime: {
59
+ id: string;
60
+ label: string | null;
61
+ startTimeLocal: string;
62
+ durationMinutes: number | null;
63
+ } | null;
64
+ meetingPoint: string | null;
65
+ capacity: number | null;
66
+ remaining: number | null;
67
+ departureStatus: "open" | "closed" | "sold_out" | "cancelled" | "on_request";
68
+ nights: number | null;
69
+ days: number | null;
70
+ ratePlans: {
71
+ id: string;
72
+ active: boolean;
73
+ name: string;
74
+ pricingModel: string;
75
+ basePrices: {
76
+ amount: number;
77
+ currencyCode: string;
78
+ }[];
79
+ roomPrices: {
80
+ amount: number;
81
+ currencyCode: string;
82
+ roomType: {
83
+ id: string;
84
+ name: string;
85
+ occupancy: {
86
+ adultsMin: number;
87
+ adultsMax: number;
88
+ childrenMax: number;
89
+ };
90
+ };
91
+ }[];
92
+ }[];
93
+ }[];
94
+ total: number;
95
+ limit: number;
96
+ offset: number;
97
+ }>;
98
+ export declare function previewStorefrontDeparturePrice(db: PostgresJsDatabase, departureId: string, input: StorefrontDeparturePricePreviewInput): Promise<{
99
+ departureId: string;
100
+ productId: string;
101
+ optionId: string | null;
102
+ currencyCode: string;
103
+ basePrice: number;
104
+ taxAmount: number;
105
+ total: number;
106
+ notes: string | null;
107
+ lineItems: {
108
+ name: string;
109
+ total: number;
110
+ quantity: number;
111
+ unitPrice: number;
112
+ }[];
113
+ } | null>;
114
+ export declare function getStorefrontProductExtensions(db: PostgresJsDatabase, productId: string, optionId?: string): Promise<{
115
+ extensions: {
116
+ id: string;
117
+ name: string;
118
+ label: string;
119
+ required: boolean;
120
+ selectable: boolean;
121
+ hasOptions: boolean;
122
+ refProductId: string | null;
123
+ thumb: string | null;
124
+ pricePerPerson: number | null;
125
+ currencyCode: string;
126
+ pricingMode: string;
127
+ defaultQuantity: number | null;
128
+ minQuantity: number | null;
129
+ maxQuantity: number | null;
130
+ }[];
131
+ items: {
132
+ id: string;
133
+ name: string;
134
+ label: string;
135
+ required: boolean;
136
+ selectable: boolean;
137
+ hasOptions: boolean;
138
+ refProductId: string | null;
139
+ thumb: string | null;
140
+ pricePerPerson: number | null;
141
+ currencyCode: string;
142
+ pricingMode: string;
143
+ defaultQuantity: number | null;
144
+ minQuantity: number | null;
145
+ maxQuantity: number | null;
146
+ }[];
147
+ details: {
148
+ [k: string]: {
149
+ description: string | null;
150
+ media: {
151
+ url: string;
152
+ alt: string | null;
153
+ }[];
154
+ };
155
+ };
156
+ currencyCode: string;
157
+ }>;
158
+ export declare function getStorefrontDepartureItinerary(db: PostgresJsDatabase, input: {
159
+ departureId: string;
160
+ productId: string;
161
+ }): Promise<{
162
+ id: string;
163
+ days: {
164
+ id: string;
165
+ title: string;
166
+ description: string | null;
167
+ thumbnail: {
168
+ url: string;
169
+ } | null;
170
+ segments: {
171
+ id: string;
172
+ title: string;
173
+ description: string | null;
174
+ }[];
175
+ }[];
176
+ } | null>;
177
+ //# sourceMappingURL=service-departures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-departures.d.ts","sourceRoot":"","sources":["../src/service-departures.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EACV,4BAA4B,EAC5B,oCAAoC,EACrC,MAAM,iBAAiB,CAAA;AA6yBxB,wBAAsB,sBAAsB,CAAC,EAAE,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQvF;AAED,wBAAsB,+BAA+B,CACnD,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BpC;AAED,wBAAsB,+BAA+B,CACnD,EAAE,EAAE,kBAAkB,EACtB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,oCAAoC;;;;;;;;;;cA7JlB,MAAM;eAAS,MAAM;kBAAY,MAAM;mBAAa,MAAM;;UA4PpF;AAED,wBAAsB,8BAA8B,CAClD,EAAE,EAAE,kBAAkB,EACtB,SAAS,EAAE,MAAM,EACjB,QAAQ,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGlB;AAED,wBAAsB,+BAA+B,CACnD,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;UA6ElD"}