@voyantjs/storefront-react 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.
Files changed (49) hide show
  1. package/dist/client.d.ts +16 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +78 -0
  4. package/dist/hooks/index.d.ts +9 -0
  5. package/dist/hooks/index.d.ts.map +1 -0
  6. package/dist/hooks/index.js +8 -0
  7. package/dist/hooks/use-storefront-departure-itinerary.d.ts +22 -0
  8. package/dist/hooks/use-storefront-departure-itinerary.d.ts.map +1 -0
  9. package/dist/hooks/use-storefront-departure-itinerary.js +12 -0
  10. package/dist/hooks/use-storefront-departure-price-preview-mutation.d.ts +35 -0
  11. package/dist/hooks/use-storefront-departure-price-preview-mutation.d.ts.map +1 -0
  12. package/dist/hooks/use-storefront-departure-price-preview-mutation.js +15 -0
  13. package/dist/hooks/use-storefront-departure.d.ts +51 -0
  14. package/dist/hooks/use-storefront-departure.d.ts.map +1 -0
  15. package/dist/hooks/use-storefront-departure.js +12 -0
  16. package/dist/hooks/use-storefront-offer.d.ts +26 -0
  17. package/dist/hooks/use-storefront-offer.d.ts.map +1 -0
  18. package/dist/hooks/use-storefront-offer.js +12 -0
  19. package/dist/hooks/use-storefront-product-departures.d.ts +55 -0
  20. package/dist/hooks/use-storefront-product-departures.d.ts.map +1 -0
  21. package/dist/hooks/use-storefront-product-departures.js +12 -0
  22. package/dist/hooks/use-storefront-product-extensions.d.ts +47 -0
  23. package/dist/hooks/use-storefront-product-extensions.d.ts.map +1 -0
  24. package/dist/hooks/use-storefront-product-extensions.js +12 -0
  25. package/dist/hooks/use-storefront-product-offers.d.ts +26 -0
  26. package/dist/hooks/use-storefront-product-offers.d.ts.map +1 -0
  27. package/dist/hooks/use-storefront-product-offers.js +12 -0
  28. package/dist/hooks/use-storefront-settings.d.ts +62 -0
  29. package/dist/hooks/use-storefront-settings.d.ts.map +1 -0
  30. package/dist/hooks/use-storefront-settings.js +12 -0
  31. package/dist/index.d.ts +8 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +7 -0
  34. package/dist/operations.d.ts +278 -0
  35. package/dist/operations.d.ts.map +1 -0
  36. package/dist/operations.js +28 -0
  37. package/dist/provider.d.ts +2 -0
  38. package/dist/provider.d.ts.map +1 -0
  39. package/dist/provider.js +1 -0
  40. package/dist/query-keys.d.ts +31 -0
  41. package/dist/query-keys.d.ts.map +1 -0
  42. package/dist/query-keys.js +14 -0
  43. package/dist/query-options.d.ts +1096 -0
  44. package/dist/query-options.d.ts.map +1 -0
  45. package/dist/query-options.js +46 -0
  46. package/dist/schemas.d.ts +244 -0
  47. package/dist/schemas.d.ts.map +1 -0
  48. package/dist/schemas.js +11 -0
  49. package/package.json +79 -0
@@ -0,0 +1,16 @@
1
+ import type { z } from "zod";
2
+ export type VoyantFetcher = (url: string, init?: RequestInit) => Promise<Response>;
3
+ export declare const defaultFetcher: VoyantFetcher;
4
+ export declare class VoyantApiError extends Error {
5
+ readonly status: number;
6
+ readonly body: unknown;
7
+ constructor(message: string, status: number, body: unknown);
8
+ }
9
+ export interface FetchWithValidationOptions {
10
+ baseUrl: string;
11
+ fetcher: VoyantFetcher;
12
+ }
13
+ export type QueryParamValue = string | number | boolean | null | undefined | Array<string | number | boolean>;
14
+ export declare function fetchWithValidation<TOut>(path: string, schema: z.ZodType<TOut>, options: FetchWithValidationOptions, init?: RequestInit): Promise<TOut>;
15
+ export declare function withQueryParams(path: string, query?: object): string;
16
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAElF,eAAO,MAAM,cAAc,EAAE,aACoB,CAAA;AAEjD,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D;AAcD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;CACvB;AAED,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;AAEpC,wBAAsB,mBAAmB,CAAC,IAAI,EAC5C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACvB,OAAO,EAAE,0BAA0B,EACnC,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAwBpE"}
package/dist/client.js ADDED
@@ -0,0 +1,78 @@
1
+ export const defaultFetcher = (url, init) => fetch(url, { credentials: "include", ...init });
2
+ export class VoyantApiError extends Error {
3
+ status;
4
+ body;
5
+ constructor(message, status, body) {
6
+ super(message);
7
+ this.name = "VoyantApiError";
8
+ this.status = status;
9
+ this.body = body;
10
+ }
11
+ }
12
+ function extractErrorMessage(status, statusText, body) {
13
+ if (typeof body === "object" && body !== null && "error" in body) {
14
+ const err = body.error;
15
+ if (typeof err === "string")
16
+ return err;
17
+ if (typeof err === "object" && err !== null && "message" in err) {
18
+ return String(err.message);
19
+ }
20
+ }
21
+ return `Voyant API error: ${status} ${statusText}`;
22
+ }
23
+ export async function fetchWithValidation(path, schema, options, init) {
24
+ const url = joinUrl(options.baseUrl, path);
25
+ const headers = new Headers(init?.headers);
26
+ if (init?.body !== undefined && !headers.has("Content-Type")) {
27
+ headers.set("Content-Type", "application/json");
28
+ }
29
+ const response = await options.fetcher(url, { ...init, headers });
30
+ if (!response.ok) {
31
+ const body = await safeJson(response);
32
+ throw new VoyantApiError(extractErrorMessage(response.status, response.statusText, body), response.status, body);
33
+ }
34
+ if (response.status === 204)
35
+ return schema.parse(undefined);
36
+ const body = await safeJson(response);
37
+ const parsed = schema.safeParse(body);
38
+ if (!parsed.success) {
39
+ throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
40
+ }
41
+ return parsed.data;
42
+ }
43
+ export function withQueryParams(path, query) {
44
+ if (!query) {
45
+ return path;
46
+ }
47
+ const params = new URLSearchParams();
48
+ for (const [key, value] of Object.entries(query)) {
49
+ if (value === undefined || value === null) {
50
+ continue;
51
+ }
52
+ if (Array.isArray(value)) {
53
+ for (const item of value) {
54
+ params.append(key, String(item));
55
+ }
56
+ continue;
57
+ }
58
+ params.set(key, String(value));
59
+ }
60
+ const serialized = params.toString();
61
+ return serialized ? `${path}?${serialized}` : path;
62
+ }
63
+ async function safeJson(response) {
64
+ const text = await response.text();
65
+ if (!text)
66
+ return undefined;
67
+ try {
68
+ return JSON.parse(text);
69
+ }
70
+ catch {
71
+ return text;
72
+ }
73
+ }
74
+ function joinUrl(baseUrl, path) {
75
+ const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
76
+ const trimmedPath = path.startsWith("/") ? path : `/${path}`;
77
+ return `${trimmedBase}${trimmedPath}`;
78
+ }
@@ -0,0 +1,9 @@
1
+ export { type UseStorefrontDepartureOptions, useStorefrontDeparture, } from "./use-storefront-departure.js";
2
+ export { type UseStorefrontDepartureItineraryOptions, useStorefrontDepartureItinerary, } from "./use-storefront-departure-itinerary.js";
3
+ export { useStorefrontDeparturePricePreviewMutation } from "./use-storefront-departure-price-preview-mutation.js";
4
+ export { type UseStorefrontOfferOptions, useStorefrontOffer } from "./use-storefront-offer.js";
5
+ export { type UseStorefrontProductDeparturesOptions, useStorefrontProductDepartures, } from "./use-storefront-product-departures.js";
6
+ export { type UseStorefrontProductExtensionsOptions, useStorefrontProductExtensions, } from "./use-storefront-product-extensions.js";
7
+ export { type UseStorefrontProductOffersOptions, useStorefrontProductOffers, } from "./use-storefront-product-offers.js";
8
+ export { type UseStorefrontSettingsOptions, useStorefrontSettings, } from "./use-storefront-settings.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EACL,KAAK,sCAAsC,EAC3C,+BAA+B,GAChC,MAAM,yCAAyC,CAAA;AAChD,OAAO,EAAE,0CAA0C,EAAE,MAAM,sDAAsD,CAAA;AACjH,OAAO,EAAE,KAAK,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9F,OAAO,EACL,KAAK,qCAAqC,EAC1C,8BAA8B,GAC/B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,KAAK,qCAAqC,EAC1C,8BAA8B,GAC/B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EACL,KAAK,iCAAiC,EACtC,0BAA0B,GAC3B,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EACL,KAAK,4BAA4B,EACjC,qBAAqB,GACtB,MAAM,8BAA8B,CAAA"}
@@ -0,0 +1,8 @@
1
+ export { useStorefrontDeparture, } from "./use-storefront-departure.js";
2
+ export { useStorefrontDepartureItinerary, } from "./use-storefront-departure-itinerary.js";
3
+ export { useStorefrontDeparturePricePreviewMutation } from "./use-storefront-departure-price-preview-mutation.js";
4
+ export { useStorefrontOffer } from "./use-storefront-offer.js";
5
+ export { useStorefrontProductDepartures, } from "./use-storefront-product-departures.js";
6
+ export { useStorefrontProductExtensions, } from "./use-storefront-product-extensions.js";
7
+ export { useStorefrontProductOffers, } from "./use-storefront-product-offers.js";
8
+ export { useStorefrontSettings, } from "./use-storefront-settings.js";
@@ -0,0 +1,22 @@
1
+ export interface UseStorefrontDepartureItineraryOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useStorefrontDepartureItinerary(productId: string | null | undefined, departureId: string | null | undefined, options?: UseStorefrontDepartureItineraryOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ id: string;
7
+ days: {
8
+ id: string;
9
+ title: string;
10
+ description: string | null;
11
+ thumbnail: {
12
+ url: string;
13
+ } | null;
14
+ segments: {
15
+ id: string;
16
+ title: string;
17
+ description: string | null;
18
+ }[];
19
+ }[];
20
+ };
21
+ }, Error>;
22
+ //# sourceMappingURL=use-storefront-departure-itinerary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-storefront-departure-itinerary.d.ts","sourceRoot":"","sources":["../../src/hooks/use-storefront-departure-itinerary.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,sCAAsC;IACrD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,+BAA+B,CAC7C,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,OAAO,GAAE,sCAA2C;;;;;;;;;;;;;;;;;UAarD"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantStorefrontContext } from "../provider.js";
4
+ import { getStorefrontDepartureItineraryQueryOptions } from "../query-options.js";
5
+ export function useStorefrontDepartureItinerary(productId, departureId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantStorefrontContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getStorefrontDepartureItineraryQueryOptions({ baseUrl, fetcher }, productId ?? "", departureId ?? ""),
10
+ enabled: enabled && Boolean(productId) && Boolean(departureId),
11
+ });
12
+ }
@@ -0,0 +1,35 @@
1
+ export declare function useStorefrontDeparturePricePreviewMutation(departureId: string | null | undefined): import("@tanstack/react-query").UseMutationResult<{
2
+ data: {
3
+ departureId: string;
4
+ productId: string;
5
+ optionId: string | null;
6
+ currencyCode: string;
7
+ basePrice: number;
8
+ taxAmount: number;
9
+ total: number;
10
+ notes: string | null;
11
+ lineItems: {
12
+ name: string;
13
+ total: number;
14
+ quantity: number;
15
+ unitPrice: number;
16
+ }[];
17
+ };
18
+ }, Error, {
19
+ pax?: {
20
+ adults?: unknown;
21
+ children?: unknown;
22
+ infants?: unknown;
23
+ } | undefined;
24
+ currencyCode?: string | null | undefined;
25
+ rooms?: {
26
+ unitId: string;
27
+ occupancy?: unknown;
28
+ quantity?: unknown;
29
+ }[] | undefined;
30
+ extras?: {
31
+ extraId: string;
32
+ quantity?: unknown;
33
+ }[] | undefined;
34
+ }, unknown>;
35
+ //# sourceMappingURL=use-storefront-departure-price-preview-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-storefront-departure-price-preview-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-storefront-departure-price-preview-mutation.ts"],"names":[],"mappings":"AAQA,wBAAgB,0CAA0C,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAYhG"}
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { useMutation } from "@tanstack/react-query";
3
+ import { previewStorefrontDeparturePrice } from "../operations.js";
4
+ import { useVoyantStorefrontContext } from "../provider.js";
5
+ export function useStorefrontDeparturePricePreviewMutation(departureId) {
6
+ const { baseUrl, fetcher } = useVoyantStorefrontContext();
7
+ return useMutation({
8
+ mutationFn: async (input) => {
9
+ if (!departureId) {
10
+ throw new Error("useStorefrontDeparturePricePreviewMutation requires a departureId");
11
+ }
12
+ return previewStorefrontDeparturePrice({ baseUrl, fetcher }, departureId, input);
13
+ },
14
+ });
15
+ }
@@ -0,0 +1,51 @@
1
+ export interface UseStorefrontDepartureOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useStorefrontDeparture(departureId: string | null | undefined, options?: UseStorefrontDepartureOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ id: string;
7
+ productId: string;
8
+ itineraryId: string;
9
+ optionId: string | null;
10
+ dateLocal: string | null;
11
+ startAt: string | null;
12
+ endAt: string | null;
13
+ timezone: string;
14
+ startTime: {
15
+ id: string;
16
+ label: string | null;
17
+ startTimeLocal: string;
18
+ durationMinutes: number | null;
19
+ } | null;
20
+ meetingPoint: string | null;
21
+ capacity: number | null;
22
+ remaining: number | null;
23
+ departureStatus: "open" | "closed" | "sold_out" | "cancelled" | "on_request";
24
+ nights: number | null;
25
+ days: number | null;
26
+ ratePlans: {
27
+ id: string;
28
+ active: boolean;
29
+ name: string;
30
+ pricingModel: string;
31
+ basePrices: {
32
+ amount: number;
33
+ currencyCode: string;
34
+ }[];
35
+ roomPrices: {
36
+ amount: number;
37
+ currencyCode: string;
38
+ roomType: {
39
+ id: string;
40
+ name: string;
41
+ occupancy: {
42
+ adultsMin: number;
43
+ adultsMax: number;
44
+ childrenMax: number;
45
+ };
46
+ };
47
+ }[];
48
+ }[];
49
+ };
50
+ }, Error>;
51
+ //# sourceMappingURL=use-storefront-departure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-storefront-departure.d.ts","sourceRoot":"","sources":["../../src/hooks/use-storefront-departure.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,6BAA6B;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,OAAO,GAAE,6BAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAS5C"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantStorefrontContext } from "../provider.js";
4
+ import { getStorefrontDepartureQueryOptions } from "../query-options.js";
5
+ export function useStorefrontDeparture(departureId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantStorefrontContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getStorefrontDepartureQueryOptions({ baseUrl, fetcher }, departureId ?? ""),
10
+ enabled: enabled && Boolean(departureId),
11
+ });
12
+ }
@@ -0,0 +1,26 @@
1
+ export interface UseStorefrontOfferOptions {
2
+ enabled?: boolean;
3
+ locale?: string;
4
+ }
5
+ export declare function useStorefrontOffer(slug: string | null | undefined, options?: UseStorefrontOfferOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ name: string;
9
+ slug: string | null;
10
+ description: string | null;
11
+ discountType: "percentage" | "fixed_amount";
12
+ discountValue: string;
13
+ currency: string | null;
14
+ applicableProductIds: string[];
15
+ applicableDepartureIds: string[];
16
+ validFrom: string | null;
17
+ validTo: string | null;
18
+ minPassengers: number | null;
19
+ imageMobileUrl: string | null;
20
+ imageDesktopUrl: string | null;
21
+ stackable: boolean;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ };
25
+ }, Error>;
26
+ //# sourceMappingURL=use-storefront-offer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-storefront-offer.d.ts","sourceRoot":"","sources":["../../src/hooks/use-storefront-offer.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,OAAO,GAAE,yBAA8B;;;;;;;;;;;;;;;;;;;;UASxC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantStorefrontContext } from "../provider.js";
4
+ import { getStorefrontOfferQueryOptions } from "../query-options.js";
5
+ export function useStorefrontOffer(slug, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantStorefrontContext();
7
+ const { enabled = true, locale } = options;
8
+ return useQuery({
9
+ ...getStorefrontOfferQueryOptions({ baseUrl, fetcher }, slug ?? "", locale),
10
+ enabled: enabled && Boolean(slug),
11
+ });
12
+ }
@@ -0,0 +1,55 @@
1
+ import { type StorefrontDepartureFilters } from "../query-options.js";
2
+ export interface UseStorefrontProductDeparturesOptions extends StorefrontDepartureFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useStorefrontProductDepartures(productId: string | null | undefined, options?: UseStorefrontProductDeparturesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ productId: string;
9
+ itineraryId: string;
10
+ optionId: string | null;
11
+ dateLocal: string | null;
12
+ startAt: string | null;
13
+ endAt: string | null;
14
+ timezone: string;
15
+ startTime: {
16
+ id: string;
17
+ label: string | null;
18
+ startTimeLocal: string;
19
+ durationMinutes: number | null;
20
+ } | null;
21
+ meetingPoint: string | null;
22
+ capacity: number | null;
23
+ remaining: number | null;
24
+ departureStatus: "open" | "closed" | "sold_out" | "cancelled" | "on_request";
25
+ nights: number | null;
26
+ days: number | null;
27
+ ratePlans: {
28
+ id: string;
29
+ active: boolean;
30
+ name: string;
31
+ pricingModel: string;
32
+ basePrices: {
33
+ amount: number;
34
+ currencyCode: string;
35
+ }[];
36
+ roomPrices: {
37
+ amount: number;
38
+ currencyCode: string;
39
+ roomType: {
40
+ id: string;
41
+ name: string;
42
+ occupancy: {
43
+ adultsMin: number;
44
+ adultsMax: number;
45
+ childrenMax: number;
46
+ };
47
+ };
48
+ }[];
49
+ }[];
50
+ }[];
51
+ total: number;
52
+ limit: number;
53
+ offset: number;
54
+ }, Error>;
55
+ //# sourceMappingURL=use-storefront-product-departures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-storefront-product-departures.d.ts","sourceRoot":"","sources":["../../src/hooks/use-storefront-product-departures.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,0BAA0B,EAChC,MAAM,qBAAqB,CAAA;AAE5B,MAAM,WAAW,qCAAsC,SAAQ,0BAA0B;IACvF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,qCAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UASpD"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantStorefrontContext } from "../provider.js";
4
+ import { getStorefrontProductDeparturesQueryOptions, } from "../query-options.js";
5
+ export function useStorefrontProductDepartures(productId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantStorefrontContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getStorefrontProductDeparturesQueryOptions({ baseUrl, fetcher }, productId ?? "", filters),
10
+ enabled: enabled && Boolean(productId),
11
+ });
12
+ }
@@ -0,0 +1,47 @@
1
+ import { type StorefrontExtensionsFilters } from "../query-options.js";
2
+ export interface UseStorefrontProductExtensionsOptions extends StorefrontExtensionsFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useStorefrontProductExtensions(productId: string | null | undefined, options?: UseStorefrontProductExtensionsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ extensions: {
7
+ id: string;
8
+ name: string;
9
+ label: string;
10
+ required: boolean;
11
+ selectable: boolean;
12
+ hasOptions: boolean;
13
+ refProductId: string | null;
14
+ thumb: string | null;
15
+ pricePerPerson: number | null;
16
+ currencyCode: string;
17
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
18
+ defaultQuantity: number | null;
19
+ minQuantity: number | null;
20
+ maxQuantity: number | null;
21
+ }[];
22
+ items: {
23
+ id: string;
24
+ name: string;
25
+ label: string;
26
+ required: boolean;
27
+ selectable: boolean;
28
+ hasOptions: boolean;
29
+ refProductId: string | null;
30
+ thumb: string | null;
31
+ pricePerPerson: number | null;
32
+ currencyCode: string;
33
+ pricingMode: "included" | "per_person" | "per_booking" | "quantity_based" | "on_request" | "free";
34
+ defaultQuantity: number | null;
35
+ minQuantity: number | null;
36
+ maxQuantity: number | null;
37
+ }[];
38
+ details: Record<string, {
39
+ description: string | null;
40
+ media: {
41
+ url: string;
42
+ alt: string | null;
43
+ }[];
44
+ }>;
45
+ currencyCode: string;
46
+ }, Error>;
47
+ //# sourceMappingURL=use-storefront-product-extensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-storefront-product-extensions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-storefront-product-extensions.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,qBAAqB,CAAA;AAE5B,MAAM,WAAW,qCAAsC,SAAQ,2BAA2B;IACxF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,qCAA0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UASpD"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantStorefrontContext } from "../provider.js";
4
+ import { getStorefrontProductExtensionsQueryOptions, } from "../query-options.js";
5
+ export function useStorefrontProductExtensions(productId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantStorefrontContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getStorefrontProductExtensionsQueryOptions({ baseUrl, fetcher }, productId ?? "", filters),
10
+ enabled: enabled && Boolean(productId),
11
+ });
12
+ }
@@ -0,0 +1,26 @@
1
+ import { type StorefrontOfferFilters } from "../query-options.js";
2
+ export interface UseStorefrontProductOffersOptions extends StorefrontOfferFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useStorefrontProductOffers(productId: string | null | undefined, options?: UseStorefrontProductOffersOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ name: string;
9
+ slug: string | null;
10
+ description: string | null;
11
+ discountType: "percentage" | "fixed_amount";
12
+ discountValue: string;
13
+ currency: string | null;
14
+ applicableProductIds: string[];
15
+ applicableDepartureIds: string[];
16
+ validFrom: string | null;
17
+ validTo: string | null;
18
+ minPassengers: number | null;
19
+ imageMobileUrl: string | null;
20
+ imageDesktopUrl: string | null;
21
+ stackable: boolean;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ }[];
25
+ }, Error>;
26
+ //# sourceMappingURL=use-storefront-product-offers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-storefront-product-offers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-storefront-product-offers.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,qBAAqB,CAAA;AAE5B,MAAM,WAAW,iCAAkC,SAAQ,sBAAsB;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,iCAAsC;;;;;;;;;;;;;;;;;;;;UAShD"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantStorefrontContext } from "../provider.js";
4
+ import { getStorefrontProductOffersQueryOptions, } from "../query-options.js";
5
+ export function useStorefrontProductOffers(productId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantStorefrontContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getStorefrontProductOffersQueryOptions({ baseUrl, fetcher }, productId ?? "", filters),
10
+ enabled: enabled && Boolean(productId),
11
+ });
12
+ }
@@ -0,0 +1,62 @@
1
+ export interface UseStorefrontSettingsOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useStorefrontSettings(options?: UseStorefrontSettingsOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ branding: {
7
+ logoUrl: string | null;
8
+ supportedLanguages: string[];
9
+ };
10
+ support: {
11
+ email: string | null;
12
+ phone: string | null;
13
+ };
14
+ legal: {
15
+ termsUrl: string | null;
16
+ privacyUrl: string | null;
17
+ defaultContractTemplateId: string | null;
18
+ };
19
+ forms: {
20
+ billing: {
21
+ fields: {
22
+ key: string;
23
+ label: string;
24
+ type: "date" | "select" | "email" | "country" | "text" | "tel" | "textarea" | "checkbox";
25
+ required: boolean;
26
+ placeholder: string | null;
27
+ description: string | null;
28
+ autocomplete: string | null;
29
+ options: {
30
+ value: string;
31
+ label: string;
32
+ }[];
33
+ }[];
34
+ };
35
+ passengers: {
36
+ fields: {
37
+ key: string;
38
+ label: string;
39
+ type: "date" | "select" | "email" | "country" | "text" | "tel" | "textarea" | "checkbox";
40
+ required: boolean;
41
+ placeholder: string | null;
42
+ description: string | null;
43
+ autocomplete: string | null;
44
+ options: {
45
+ value: string;
46
+ label: string;
47
+ }[];
48
+ }[];
49
+ };
50
+ };
51
+ payment: {
52
+ defaultMethod: "voucher" | "card" | "bank_transfer" | "cash" | "invoice" | null;
53
+ methods: {
54
+ code: "voucher" | "card" | "bank_transfer" | "cash" | "invoice";
55
+ label: string;
56
+ description: string | null;
57
+ enabled: boolean;
58
+ }[];
59
+ };
60
+ };
61
+ }, Error>;
62
+ //# sourceMappingURL=use-storefront-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-storefront-settings.d.ts","sourceRoot":"","sources":["../../src/hooks/use-storefront-settings.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,4BAA4B;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,4BAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQ/E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantStorefrontContext } from "../provider.js";
4
+ import { getStorefrontSettingsQueryOptions } from "../query-options.js";
5
+ export function useStorefrontSettings(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantStorefrontContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getStorefrontSettingsQueryOptions({ baseUrl, fetcher }),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,8 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, withQueryParams, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { getStorefrontDeparture, getStorefrontDepartureItinerary, getStorefrontOfferBySlug, getStorefrontSettings, listStorefrontProductDepartures, listStorefrontProductExtensions, listStorefrontProductOffers, previewStorefrontDeparturePrice, } from "./operations.js";
4
+ export { useVoyantStorefrontContext, type VoyantStorefrontContextValue, VoyantStorefrontProvider, type VoyantStorefrontProviderProps, } from "./provider.js";
5
+ export { storefrontQueryKeys } from "./query-keys.js";
6
+ export { getStorefrontDepartureItineraryQueryOptions, getStorefrontDepartureQueryOptions, getStorefrontOfferQueryOptions, getStorefrontProductDeparturesQueryOptions, getStorefrontProductExtensionsQueryOptions, getStorefrontProductOffersQueryOptions, getStorefrontSettingsQueryOptions, } from "./query-options.js";
7
+ export * from "./schemas.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,EAClB,eAAe,GAChB,MAAM,aAAa,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,wBAAwB,EACxB,qBAAqB,EACrB,+BAA+B,EAC/B,+BAA+B,EAC/B,2BAA2B,EAC3B,+BAA+B,GAChC,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,0BAA0B,EAC1B,KAAK,4BAA4B,EACjC,wBAAwB,EACxB,KAAK,6BAA6B,GACnC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EACL,2CAA2C,EAC3C,kCAAkC,EAClC,8BAA8B,EAC9B,0CAA0C,EAC1C,0CAA0C,EAC1C,sCAAsC,EACtC,iCAAiC,GAClC,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, withQueryParams, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { getStorefrontDeparture, getStorefrontDepartureItinerary, getStorefrontOfferBySlug, getStorefrontSettings, listStorefrontProductDepartures, listStorefrontProductExtensions, listStorefrontProductOffers, previewStorefrontDeparturePrice, } from "./operations.js";
4
+ export { useVoyantStorefrontContext, VoyantStorefrontProvider, } from "./provider.js";
5
+ export { storefrontQueryKeys } from "./query-keys.js";
6
+ export { getStorefrontDepartureItineraryQueryOptions, getStorefrontDepartureQueryOptions, getStorefrontOfferQueryOptions, getStorefrontProductDeparturesQueryOptions, getStorefrontProductExtensionsQueryOptions, getStorefrontProductOffersQueryOptions, getStorefrontSettingsQueryOptions, } from "./query-options.js";
7
+ export * from "./schemas.js";