@voyantjs/travel-composer-react 0.55.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/README.md +30 -0
- package/dist/cache.d.ts +9 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +21 -0
- package/dist/client.d.ts +15 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +51 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/use-price-trip-draft.d.ts +3 -0
- package/dist/hooks/use-price-trip-draft.d.ts.map +1 -0
- package/dist/hooks/use-price-trip-draft.js +17 -0
- package/dist/hooks/use-price-trip.d.ts +3 -0
- package/dist/hooks/use-price-trip.d.ts.map +1 -0
- package/dist/hooks/use-price-trip.js +17 -0
- package/dist/hooks/use-reserve-trip-draft.d.ts +3 -0
- package/dist/hooks/use-reserve-trip-draft.d.ts.map +1 -0
- package/dist/hooks/use-reserve-trip-draft.js +17 -0
- package/dist/hooks/use-reserve-trip.d.ts +3 -0
- package/dist/hooks/use-reserve-trip.d.ts.map +1 -0
- package/dist/hooks/use-reserve-trip.js +17 -0
- package/dist/hooks/use-trip-checkout.d.ts +3 -0
- package/dist/hooks/use-trip-checkout.d.ts.map +1 -0
- package/dist/hooks/use-trip-checkout.js +17 -0
- package/dist/hooks/use-trip-components.d.ts +40 -0
- package/dist/hooks/use-trip-components.d.ts.map +1 -0
- package/dist/hooks/use-trip-components.js +13 -0
- package/dist/hooks/use-trip-draft.d.ts +5 -0
- package/dist/hooks/use-trip-draft.d.ts.map +1 -0
- package/dist/hooks/use-trip-draft.js +13 -0
- package/dist/hooks/use-trip.d.ts +5 -0
- package/dist/hooks/use-trip.d.ts.map +1 -0
- package/dist/hooks/use-trip.js +13 -0
- package/dist/hooks/use-trips.d.ts +6 -0
- package/dist/hooks/use-trips.d.ts.map +1 -0
- package/dist/hooks/use-trips.js +12 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/operations.d.ts +150 -0
- package/dist/operations.d.ts.map +1 -0
- package/dist/operations.js +77 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +10 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +9 -0
- package/dist/query-options.d.ts +167 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +22 -0
- package/dist/schemas.d.ts +34 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +13 -0
- package/package.json +85 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @voyantjs/travel-composer-react
|
|
2
|
+
|
|
3
|
+
React client utilities for `@voyantjs/travel-composer`.
|
|
4
|
+
|
|
5
|
+
This package exposes admin/public API clients, validation-aware operations,
|
|
6
|
+
TanStack Query keys/options, cache writers, provider wiring, and hooks for Trip
|
|
7
|
+
Envelope composition flows. It supports trip creation, component add, pricing,
|
|
8
|
+
reserve, checkout handoff, and support-facing component cancellation preview /
|
|
9
|
+
cancel operations. Draft is represented as a trip lifecycle status, not as the
|
|
10
|
+
customer/admin object name.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @voyantjs/travel-composer-react @voyantjs/travel-composer
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Exports
|
|
19
|
+
|
|
20
|
+
| Entry | Description |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| `.` | Client, provider, hooks, operations, schemas, and query helpers |
|
|
23
|
+
| `./provider` | `VoyantTravelComposerProvider` and context helpers |
|
|
24
|
+
| `./hooks` | React hooks for Trips, pricing, reserve, checkout, and components |
|
|
25
|
+
| `./client` | Fetcher and API error utilities |
|
|
26
|
+
| `./query-keys` | Stable TanStack Query keys |
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
Apache-2.0
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import type { PriceTripResult, ReserveTripResult, StartCheckoutResult } from "@voyantjs/travel-composer";
|
|
3
|
+
type TripLikeResult = Pick<PriceTripResult | ReserveTripResult | StartCheckoutResult, "envelope" | "components">;
|
|
4
|
+
export declare function writeTripCache(queryClient: QueryClient, result: TripLikeResult): void;
|
|
5
|
+
export declare function writePriceTripCache(queryClient: QueryClient, result: PriceTripResult): void;
|
|
6
|
+
export declare function writeReserveTripCache(queryClient: QueryClient, result: ReserveTripResult): void;
|
|
7
|
+
export declare function writeTripCheckoutCache(queryClient: QueryClient, result: StartCheckoutResult): void;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AAIlC,KAAK,cAAc,GAAG,IAAI,CACxB,eAAe,GAAG,iBAAiB,GAAG,mBAAmB,EACzD,UAAU,GAAG,YAAY,CAC1B,CAAA;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,QAU9E;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,QAGpF;AAED,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,QAExF;AAED,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,mBAAmB,QAG3F"}
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { travelComposerQueryKeys } from "./query-keys.js";
|
|
3
|
+
export function writeTripCache(queryClient, result) {
|
|
4
|
+
void queryClient.invalidateQueries({ queryKey: travelComposerQueryKeys.trips() });
|
|
5
|
+
queryClient.setQueryData(travelComposerQueryKeys.trip(result.envelope.id), {
|
|
6
|
+
envelope: result.envelope,
|
|
7
|
+
components: result.components,
|
|
8
|
+
});
|
|
9
|
+
queryClient.setQueryData(travelComposerQueryKeys.components(result.envelope.id), result.components);
|
|
10
|
+
}
|
|
11
|
+
export function writePriceTripCache(queryClient, result) {
|
|
12
|
+
writeTripCache(queryClient, result);
|
|
13
|
+
queryClient.setQueryData(travelComposerQueryKeys.pricing(result.envelope.id), result.pricing);
|
|
14
|
+
}
|
|
15
|
+
export function writeReserveTripCache(queryClient, result) {
|
|
16
|
+
writeTripCache(queryClient, result);
|
|
17
|
+
}
|
|
18
|
+
export function writeTripCheckoutCache(queryClient, result) {
|
|
19
|
+
writeTripCache(queryClient, result);
|
|
20
|
+
queryClient.setQueryData(travelComposerQueryKeys.checkout(result.envelope.id), result.target);
|
|
21
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
surface?: "admin" | "public";
|
|
13
|
+
}
|
|
14
|
+
export declare function fetchWithValidation<TOut>(path: string, schema: z.ZodType<TOut>, options: FetchWithValidationOptions, init?: RequestInit): Promise<TOut>;
|
|
15
|
+
//# 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;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAA;CAC7B;AAED,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,CAuBf"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
export async function fetchWithValidation(path, schema, options, init) {
|
|
13
|
+
const headers = new Headers(init?.headers);
|
|
14
|
+
if (init?.body !== undefined && !headers.has("Content-Type")) {
|
|
15
|
+
headers.set("Content-Type", "application/json");
|
|
16
|
+
}
|
|
17
|
+
const response = await options.fetcher(joinUrl(options.baseUrl, path), { ...init, headers });
|
|
18
|
+
const body = await safeJson(response);
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
throw new VoyantApiError(errorMessage(response, body), response.status, body);
|
|
21
|
+
}
|
|
22
|
+
const parsed = schema.safeParse(body);
|
|
23
|
+
if (!parsed.success) {
|
|
24
|
+
throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
|
|
25
|
+
}
|
|
26
|
+
return parsed.data;
|
|
27
|
+
}
|
|
28
|
+
function errorMessage(response, body) {
|
|
29
|
+
if (typeof body === "object" && body !== null && "error" in body) {
|
|
30
|
+
const error = body.error;
|
|
31
|
+
if (typeof error === "string")
|
|
32
|
+
return error;
|
|
33
|
+
}
|
|
34
|
+
return `Voyant API error: ${response.status} ${response.statusText}`;
|
|
35
|
+
}
|
|
36
|
+
async function safeJson(response) {
|
|
37
|
+
const text = await response.text();
|
|
38
|
+
if (!text)
|
|
39
|
+
return undefined;
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(text);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return text;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function joinUrl(baseUrl, path) {
|
|
48
|
+
const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
49
|
+
const trimmedPath = path.startsWith("/") ? path : `/${path}`;
|
|
50
|
+
return `${trimmedBase}${trimmedPath}`;
|
|
51
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { usePriceTrip } from "./use-price-trip.js";
|
|
2
|
+
export { useReserveTrip } from "./use-reserve-trip.js";
|
|
3
|
+
export { type UseTripOptions, useTrip } from "./use-trip.js";
|
|
4
|
+
export { useTripCheckout } from "./use-trip-checkout.js";
|
|
5
|
+
export { type UseTripComponentsOptions, useTripComponents } from "./use-trip-components.js";
|
|
6
|
+
export { type UseTripsOptions, useTrips } from "./use-trips.js";
|
|
7
|
+
//# 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,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,KAAK,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,KAAK,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,eAAe,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { usePriceTrip } from "./use-price-trip.js";
|
|
2
|
+
export { useReserveTrip } from "./use-reserve-trip.js";
|
|
3
|
+
export { useTrip } from "./use-trip.js";
|
|
4
|
+
export { useTripCheckout } from "./use-trip-checkout.js";
|
|
5
|
+
export { useTripComponents } from "./use-trip-components.js";
|
|
6
|
+
export { useTrips } from "./use-trips.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type PriceTripDraftBody } from "../operations.js";
|
|
2
|
+
export declare function usePriceTripDraft(envelopeId: string | null | undefined): import("@tanstack/react-query").UseMutationResult<import("@voyantjs/travel-composer").PriceDraftResult, Error, PriceTripDraftBody, unknown>;
|
|
3
|
+
//# sourceMappingURL=use-price-trip-draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-price-trip-draft.d.ts","sourceRoot":"","sources":["../../src/hooks/use-price-trip-draft.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,kBAAkB,CAAA;AAG1E,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,+IAWtE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { writePriceTripDraftCache } from "../cache.js";
|
|
4
|
+
import { priceTripDraft } from "../operations.js";
|
|
5
|
+
import { useVoyantTravelComposerContext } from "../provider.js";
|
|
6
|
+
export function usePriceTripDraft(envelopeId) {
|
|
7
|
+
const { baseUrl, fetcher } = useVoyantTravelComposerContext();
|
|
8
|
+
const queryClient = useQueryClient();
|
|
9
|
+
return useMutation({
|
|
10
|
+
mutationFn: async (input) => {
|
|
11
|
+
if (!envelopeId)
|
|
12
|
+
throw new Error("usePriceTripDraft requires an envelopeId");
|
|
13
|
+
return priceTripDraft({ baseUrl, fetcher }, envelopeId, input);
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (result) => writePriceTripDraftCache(queryClient, result),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type PriceTripBody } from "../operations.js";
|
|
2
|
+
export declare function usePriceTrip(envelopeId: string | null | undefined): import("@tanstack/react-query").UseMutationResult<import("@voyantjs/travel-composer").PriceTripResult, Error, PriceTripBody, unknown>;
|
|
3
|
+
//# sourceMappingURL=use-price-trip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-price-trip.d.ts","sourceRoot":"","sources":["../../src/hooks/use-price-trip.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,aAAa,EAAa,MAAM,kBAAkB,CAAA;AAGhE,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,yIAWjE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { writePriceTripCache } from "../cache.js";
|
|
4
|
+
import { priceTrip } from "../operations.js";
|
|
5
|
+
import { useVoyantTravelComposerContext } from "../provider.js";
|
|
6
|
+
export function usePriceTrip(envelopeId) {
|
|
7
|
+
const { baseUrl, fetcher } = useVoyantTravelComposerContext();
|
|
8
|
+
const queryClient = useQueryClient();
|
|
9
|
+
return useMutation({
|
|
10
|
+
mutationFn: async (input) => {
|
|
11
|
+
if (!envelopeId)
|
|
12
|
+
throw new Error("usePriceTrip requires an envelopeId");
|
|
13
|
+
return priceTrip({ baseUrl, fetcher }, envelopeId, input);
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (result) => writePriceTripCache(queryClient, result),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ReserveTripDraftBody } from "../operations.js";
|
|
2
|
+
export declare function useReserveTripDraft(envelopeId: string | null | undefined): import("@tanstack/react-query").UseMutationResult<import("@voyantjs/travel-composer").ReserveDraftResult, Error, ReserveTripDraftBody, unknown>;
|
|
3
|
+
//# sourceMappingURL=use-reserve-trip-draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reserve-trip-draft.d.ts","sourceRoot":"","sources":["../../src/hooks/use-reserve-trip-draft.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,oBAAoB,EAAoB,MAAM,kBAAkB,CAAA;AAG9E,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,mJAWxE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { writeReserveTripDraftCache } from "../cache.js";
|
|
4
|
+
import { reserveTripDraft } from "../operations.js";
|
|
5
|
+
import { useVoyantTravelComposerContext } from "../provider.js";
|
|
6
|
+
export function useReserveTripDraft(envelopeId) {
|
|
7
|
+
const { baseUrl, fetcher } = useVoyantTravelComposerContext();
|
|
8
|
+
const queryClient = useQueryClient();
|
|
9
|
+
return useMutation({
|
|
10
|
+
mutationFn: async (input = {}) => {
|
|
11
|
+
if (!envelopeId)
|
|
12
|
+
throw new Error("useReserveTripDraft requires an envelopeId");
|
|
13
|
+
return reserveTripDraft({ baseUrl, fetcher }, envelopeId, input);
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (result) => writeReserveTripDraftCache(queryClient, result),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ReserveTripBody } from "../operations.js";
|
|
2
|
+
export declare function useReserveTrip(envelopeId: string | null | undefined): import("@tanstack/react-query").UseMutationResult<import("@voyantjs/travel-composer").ReserveTripResult, Error, ReserveTripBody, unknown>;
|
|
3
|
+
//# sourceMappingURL=use-reserve-trip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-reserve-trip.d.ts","sourceRoot":"","sources":["../../src/hooks/use-reserve-trip.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,eAAe,EAAe,MAAM,kBAAkB,CAAA;AAGpE,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,6IAWnE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { writeReserveTripCache } from "../cache.js";
|
|
4
|
+
import { reserveTrip } from "../operations.js";
|
|
5
|
+
import { useVoyantTravelComposerContext } from "../provider.js";
|
|
6
|
+
export function useReserveTrip(envelopeId) {
|
|
7
|
+
const { baseUrl, fetcher } = useVoyantTravelComposerContext();
|
|
8
|
+
const queryClient = useQueryClient();
|
|
9
|
+
return useMutation({
|
|
10
|
+
mutationFn: async (input = {}) => {
|
|
11
|
+
if (!envelopeId)
|
|
12
|
+
throw new Error("useReserveTrip requires an envelopeId");
|
|
13
|
+
return reserveTrip({ baseUrl, fetcher }, envelopeId, input);
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (result) => writeReserveTripCache(queryClient, result),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type StartTripCheckoutBody } from "../operations.js";
|
|
2
|
+
export declare function useTripCheckout(envelopeId: string | null | undefined): import("@tanstack/react-query").UseMutationResult<import("@voyantjs/travel-composer").StartCheckoutResult, Error, StartTripCheckoutBody, unknown>;
|
|
3
|
+
//# sourceMappingURL=use-trip-checkout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-trip-checkout.d.ts","sourceRoot":"","sources":["../../src/hooks/use-trip-checkout.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,qBAAqB,EAAqB,MAAM,kBAAkB,CAAA;AAGhF,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,qJAWpE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { writeTripCheckoutCache } from "../cache.js";
|
|
4
|
+
import { startTripCheckout } from "../operations.js";
|
|
5
|
+
import { useVoyantTravelComposerContext } from "../provider.js";
|
|
6
|
+
export function useTripCheckout(envelopeId) {
|
|
7
|
+
const { baseUrl, fetcher } = useVoyantTravelComposerContext();
|
|
8
|
+
const queryClient = useQueryClient();
|
|
9
|
+
return useMutation({
|
|
10
|
+
mutationFn: async (input) => {
|
|
11
|
+
if (!envelopeId)
|
|
12
|
+
throw new Error("useTripCheckout requires an envelopeId");
|
|
13
|
+
return startTripCheckout({ baseUrl, fetcher }, envelopeId, input);
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (result) => writeTripCheckoutCache(queryClient, result),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface UseTripComponentsOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useTripComponents(envelopeId: string | null | undefined, options?: UseTripComponentsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
status: "draft" | "priced" | "checkout_started" | "booked" | "failed" | "cancelled" | "unavailable" | "held" | "removed";
|
|
7
|
+
title: string | null;
|
|
8
|
+
description: string | null;
|
|
9
|
+
bookingGroupId: string | null;
|
|
10
|
+
orderId: string | null;
|
|
11
|
+
paymentSessionId: string | null;
|
|
12
|
+
createdAt: Date;
|
|
13
|
+
updatedAt: Date;
|
|
14
|
+
envelopeId: string;
|
|
15
|
+
sequence: number;
|
|
16
|
+
kind: "catalog_booking" | "manual_placeholder" | "flight_placeholder" | "flight_order" | "external_order";
|
|
17
|
+
entityModule: string | null;
|
|
18
|
+
entityId: string | null;
|
|
19
|
+
sourceKind: string | null;
|
|
20
|
+
sourceConnectionId: string | null;
|
|
21
|
+
sourceRef: string | null;
|
|
22
|
+
bookingDraftId: string | null;
|
|
23
|
+
catalogQuoteId: string | null;
|
|
24
|
+
bookingId: string | null;
|
|
25
|
+
providerRef: string | null;
|
|
26
|
+
supplierRef: string | null;
|
|
27
|
+
componentCurrency: string | null;
|
|
28
|
+
componentSubtotalAmountCents: number | null;
|
|
29
|
+
componentTaxAmountCents: number | null;
|
|
30
|
+
componentTotalAmountCents: number | null;
|
|
31
|
+
pricingSnapshot: import("@voyantjs/travel-composer").TripComponentPricingSnapshot | null;
|
|
32
|
+
taxLines: import("@voyantjs/travel-composer").TripComponentTaxLineSnapshot[] | null;
|
|
33
|
+
cancellationSnapshot: Record<string, unknown> | null;
|
|
34
|
+
holdToken: string | null;
|
|
35
|
+
holdExpiresAt: Date | null;
|
|
36
|
+
priceExpiresAt: Date | null;
|
|
37
|
+
warningCodes: string[];
|
|
38
|
+
metadata: Record<string, unknown>;
|
|
39
|
+
}[], Error>;
|
|
40
|
+
//# sourceMappingURL=use-trip-components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-trip-components.d.ts","sourceRoot":"","sources":["../../src/hooks/use-trip-components.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACrC,OAAO,GAAE,wBAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAUvC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantTravelComposerContext } from "../provider.js";
|
|
4
|
+
import { getTripComponentsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useTripComponents(envelopeId, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantTravelComposerContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
const id = envelopeId ?? "";
|
|
9
|
+
return useQuery({
|
|
10
|
+
...getTripComponentsQueryOptions({ baseUrl, fetcher }, id),
|
|
11
|
+
enabled: enabled && Boolean(envelopeId),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface UseTripDraftOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useTripDraft(envelopeId: string | null | undefined, options?: UseTripDraftOptions): import("@tanstack/react-query").UseQueryResult<import("@voyantjs/travel-composer").TripDraft, Error>;
|
|
5
|
+
//# sourceMappingURL=use-trip-draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-trip-draft.d.ts","sourceRoot":"","sources":["../../src/hooks/use-trip-draft.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACrC,OAAO,GAAE,mBAAwB,wGAUlC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantTravelComposerContext } from "../provider.js";
|
|
4
|
+
import { getTripDraftQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useTripDraft(envelopeId, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantTravelComposerContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
const id = envelopeId ?? "";
|
|
9
|
+
return useQuery({
|
|
10
|
+
...getTripDraftQueryOptions({ baseUrl, fetcher }, id),
|
|
11
|
+
enabled: enabled && Boolean(envelopeId),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface UseTripOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useTrip(envelopeId: string | null | undefined, options?: UseTripOptions): import("@tanstack/react-query").UseQueryResult<import("@voyantjs/travel-composer").Trip, Error>;
|
|
5
|
+
//# sourceMappingURL=use-trip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-trip.d.ts","sourceRoot":"","sources":["../../src/hooks/use-trip.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,cAAmB,mGAS1F"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantTravelComposerContext } from "../provider.js";
|
|
4
|
+
import { getTripQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useTrip(envelopeId, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantTravelComposerContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
const id = envelopeId ?? "";
|
|
9
|
+
return useQuery({
|
|
10
|
+
...getTripQueryOptions({ baseUrl, fetcher }, id),
|
|
11
|
+
enabled: enabled && Boolean(envelopeId),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ListTripsParams } from "../operations.js";
|
|
2
|
+
export interface UseTripsOptions {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useTrips(params?: ListTripsParams, options?: UseTripsOptions): import("@tanstack/react-query").UseQueryResult<import("@voyantjs/travel-composer").TripListResult, Error>;
|
|
6
|
+
//# sourceMappingURL=use-trips.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-trips.d.ts","sourceRoot":"","sources":["../../src/hooks/use-trips.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAIvD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,QAAQ,CAAC,MAAM,GAAE,eAAoB,EAAE,OAAO,GAAE,eAAoB,6GAQnF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantTravelComposerContext } from "../provider.js";
|
|
4
|
+
import { listTripsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useTrips(params = {}, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantTravelComposerContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...listTripsQueryOptions({ baseUrl, fetcher }, params),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { writePriceTripCache, writeReserveTripCache, writeTripCache, writeTripCheckoutCache, } from "./cache.js";
|
|
2
|
+
export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, } from "./client.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export { type AddTripComponentBody, addTripComponent, type CancelTripComponentsBody, type CreateTripBody, cancelTripComponents, createTrip, getTrip, type ListTripsParams, listTrips, type PreviewTripCancellationBody, type PriceTripBody, previewTripCancellation, priceTrip, type ReserveTripBody, removeTripComponent, reserveTrip, type StartTripCheckoutBody, startTripCheckout, type UpdateTripComponentBody, updateTripComponent, } from "./operations.js";
|
|
5
|
+
export { useVoyantTravelComposerContext, type VoyantTravelComposerContextValue, VoyantTravelComposerProvider, type VoyantTravelComposerProviderProps, } from "./provider.js";
|
|
6
|
+
export { travelComposerQueryKeys } from "./query-keys.js";
|
|
7
|
+
export { getTripComponentsQueryOptions, getTripQueryOptions, listTripsQueryOptions, } from "./query-options.js";
|
|
8
|
+
export * from "./schemas.js";
|
|
9
|
+
//# 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,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,GACvB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,oBAAoB,EACpB,UAAU,EACV,OAAO,EACP,KAAK,eAAe,EACpB,SAAS,EACT,KAAK,2BAA2B,EAChC,KAAK,aAAa,EAClB,uBAAuB,EACvB,SAAS,EACT,KAAK,eAAe,EACpB,mBAAmB,EACnB,WAAW,EACX,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,KAAK,uBAAuB,EAC5B,mBAAmB,GACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,8BAA8B,EAC9B,KAAK,gCAAgC,EACrC,4BAA4B,EAC5B,KAAK,iCAAiC,GACvC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EACL,6BAA6B,EAC7B,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { writePriceTripCache, writeReserveTripCache, writeTripCache, writeTripCheckoutCache, } from "./cache.js";
|
|
2
|
+
export { defaultFetcher, fetchWithValidation, VoyantApiError, } from "./client.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export { addTripComponent, cancelTripComponents, createTrip, getTrip, listTrips, previewTripCancellation, priceTrip, removeTripComponent, reserveTrip, startTripCheckout, updateTripComponent, } from "./operations.js";
|
|
5
|
+
export { useVoyantTravelComposerContext, VoyantTravelComposerProvider, } from "./provider.js";
|
|
6
|
+
export { travelComposerQueryKeys } from "./query-keys.js";
|
|
7
|
+
export { getTripComponentsQueryOptions, getTripQueryOptions, listTripsQueryOptions, } from "./query-options.js";
|
|
8
|
+
export * from "./schemas.js";
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { CancelTripComponentsInput, CreateTripComponentBodyInput, CreateTripEnvelopeInput, PreviewTripCancellationInput, PriceTripInput, ReserveTripInput, StartTripCheckoutInput, TripEnvelopeStatus, TripsListSortDir, TripsListSortField } from "@voyantjs/travel-composer";
|
|
2
|
+
import { type FetchWithValidationOptions } from "./client.js";
|
|
3
|
+
export type ListTripsParams = {
|
|
4
|
+
status?: TripEnvelopeStatus;
|
|
5
|
+
search?: string;
|
|
6
|
+
productId?: string;
|
|
7
|
+
hospitalityId?: string;
|
|
8
|
+
cruiseId?: string;
|
|
9
|
+
hasFlight?: boolean;
|
|
10
|
+
totalMinCents?: number;
|
|
11
|
+
totalMaxCents?: number;
|
|
12
|
+
createdFrom?: string;
|
|
13
|
+
createdTo?: string;
|
|
14
|
+
sortBy?: TripsListSortField;
|
|
15
|
+
sortDir?: TripsListSortDir;
|
|
16
|
+
limit?: number;
|
|
17
|
+
offset?: number;
|
|
18
|
+
};
|
|
19
|
+
export type CreateTripBody = Omit<CreateTripEnvelopeInput, "travelerParty" | "constraints"> & Partial<Pick<CreateTripEnvelopeInput, "travelerParty" | "constraints">>;
|
|
20
|
+
export type AddTripComponentBody = Omit<CreateTripComponentBodyInput, "sequence" | "metadata"> & Partial<Pick<CreateTripComponentBodyInput, "sequence" | "metadata">>;
|
|
21
|
+
export type UpdateTripComponentBody = {
|
|
22
|
+
sequence?: number;
|
|
23
|
+
status?: string;
|
|
24
|
+
description?: string | null;
|
|
25
|
+
catalogRef?: unknown;
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
warningCodes?: string[];
|
|
28
|
+
};
|
|
29
|
+
export type PriceTripBody = Omit<PriceTripInput, "envelopeId">;
|
|
30
|
+
export type ReserveTripBody = Omit<ReserveTripInput, "envelopeId">;
|
|
31
|
+
export type StartTripCheckoutBody = Omit<StartTripCheckoutInput, "envelopeId">;
|
|
32
|
+
export type PreviewTripCancellationBody = Omit<PreviewTripCancellationInput, "envelopeId" | "request"> & Partial<Pick<PreviewTripCancellationInput, "request">>;
|
|
33
|
+
export type CancelTripComponentsBody = Omit<CancelTripComponentsInput, "envelopeId" | "request"> & Partial<Pick<CancelTripComponentsInput, "request">>;
|
|
34
|
+
export declare function listTrips(client: FetchWithValidationOptions, params?: ListTripsParams): Promise<import("@voyantjs/travel-composer").TripListResult>;
|
|
35
|
+
export declare function createTrip(client: FetchWithValidationOptions, input: CreateTripBody): Promise<import("@voyantjs/travel-composer").Trip>;
|
|
36
|
+
export declare function getTrip(client: FetchWithValidationOptions, envelopeId: string): Promise<import("@voyantjs/travel-composer").Trip>;
|
|
37
|
+
export declare function addTripComponent(client: FetchWithValidationOptions, envelopeId: string, input: AddTripComponentBody): Promise<{
|
|
38
|
+
id: string;
|
|
39
|
+
status: "draft" | "priced" | "checkout_started" | "booked" | "failed" | "cancelled" | "unavailable" | "held" | "removed";
|
|
40
|
+
title: string | null;
|
|
41
|
+
description: string | null;
|
|
42
|
+
bookingGroupId: string | null;
|
|
43
|
+
orderId: string | null;
|
|
44
|
+
paymentSessionId: string | null;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
updatedAt: Date;
|
|
47
|
+
envelopeId: string;
|
|
48
|
+
sequence: number;
|
|
49
|
+
kind: "catalog_booking" | "manual_placeholder" | "flight_placeholder" | "flight_order" | "external_order";
|
|
50
|
+
entityModule: string | null;
|
|
51
|
+
entityId: string | null;
|
|
52
|
+
sourceKind: string | null;
|
|
53
|
+
sourceConnectionId: string | null;
|
|
54
|
+
sourceRef: string | null;
|
|
55
|
+
bookingDraftId: string | null;
|
|
56
|
+
catalogQuoteId: string | null;
|
|
57
|
+
bookingId: string | null;
|
|
58
|
+
providerRef: string | null;
|
|
59
|
+
supplierRef: string | null;
|
|
60
|
+
componentCurrency: string | null;
|
|
61
|
+
componentSubtotalAmountCents: number | null;
|
|
62
|
+
componentTaxAmountCents: number | null;
|
|
63
|
+
componentTotalAmountCents: number | null;
|
|
64
|
+
pricingSnapshot: import("@voyantjs/travel-composer").TripComponentPricingSnapshot | null;
|
|
65
|
+
taxLines: import("@voyantjs/travel-composer").TripComponentTaxLineSnapshot[] | null;
|
|
66
|
+
cancellationSnapshot: Record<string, unknown> | null;
|
|
67
|
+
holdToken: string | null;
|
|
68
|
+
holdExpiresAt: Date | null;
|
|
69
|
+
priceExpiresAt: Date | null;
|
|
70
|
+
warningCodes: string[];
|
|
71
|
+
metadata: Record<string, unknown>;
|
|
72
|
+
}>;
|
|
73
|
+
export declare function removeTripComponent(client: FetchWithValidationOptions, componentId: string): Promise<{
|
|
74
|
+
id: string;
|
|
75
|
+
status: "draft" | "priced" | "checkout_started" | "booked" | "failed" | "cancelled" | "unavailable" | "held" | "removed";
|
|
76
|
+
title: string | null;
|
|
77
|
+
description: string | null;
|
|
78
|
+
bookingGroupId: string | null;
|
|
79
|
+
orderId: string | null;
|
|
80
|
+
paymentSessionId: string | null;
|
|
81
|
+
createdAt: Date;
|
|
82
|
+
updatedAt: Date;
|
|
83
|
+
envelopeId: string;
|
|
84
|
+
sequence: number;
|
|
85
|
+
kind: "catalog_booking" | "manual_placeholder" | "flight_placeholder" | "flight_order" | "external_order";
|
|
86
|
+
entityModule: string | null;
|
|
87
|
+
entityId: string | null;
|
|
88
|
+
sourceKind: string | null;
|
|
89
|
+
sourceConnectionId: string | null;
|
|
90
|
+
sourceRef: string | null;
|
|
91
|
+
bookingDraftId: string | null;
|
|
92
|
+
catalogQuoteId: string | null;
|
|
93
|
+
bookingId: string | null;
|
|
94
|
+
providerRef: string | null;
|
|
95
|
+
supplierRef: string | null;
|
|
96
|
+
componentCurrency: string | null;
|
|
97
|
+
componentSubtotalAmountCents: number | null;
|
|
98
|
+
componentTaxAmountCents: number | null;
|
|
99
|
+
componentTotalAmountCents: number | null;
|
|
100
|
+
pricingSnapshot: import("@voyantjs/travel-composer").TripComponentPricingSnapshot | null;
|
|
101
|
+
taxLines: import("@voyantjs/travel-composer").TripComponentTaxLineSnapshot[] | null;
|
|
102
|
+
cancellationSnapshot: Record<string, unknown> | null;
|
|
103
|
+
holdToken: string | null;
|
|
104
|
+
holdExpiresAt: Date | null;
|
|
105
|
+
priceExpiresAt: Date | null;
|
|
106
|
+
warningCodes: string[];
|
|
107
|
+
metadata: Record<string, unknown>;
|
|
108
|
+
}>;
|
|
109
|
+
export declare function updateTripComponent(client: FetchWithValidationOptions, componentId: string, input: UpdateTripComponentBody): Promise<{
|
|
110
|
+
id: string;
|
|
111
|
+
status: "draft" | "priced" | "checkout_started" | "booked" | "failed" | "cancelled" | "unavailable" | "held" | "removed";
|
|
112
|
+
title: string | null;
|
|
113
|
+
description: string | null;
|
|
114
|
+
bookingGroupId: string | null;
|
|
115
|
+
orderId: string | null;
|
|
116
|
+
paymentSessionId: string | null;
|
|
117
|
+
createdAt: Date;
|
|
118
|
+
updatedAt: Date;
|
|
119
|
+
envelopeId: string;
|
|
120
|
+
sequence: number;
|
|
121
|
+
kind: "catalog_booking" | "manual_placeholder" | "flight_placeholder" | "flight_order" | "external_order";
|
|
122
|
+
entityModule: string | null;
|
|
123
|
+
entityId: string | null;
|
|
124
|
+
sourceKind: string | null;
|
|
125
|
+
sourceConnectionId: string | null;
|
|
126
|
+
sourceRef: string | null;
|
|
127
|
+
bookingDraftId: string | null;
|
|
128
|
+
catalogQuoteId: string | null;
|
|
129
|
+
bookingId: string | null;
|
|
130
|
+
providerRef: string | null;
|
|
131
|
+
supplierRef: string | null;
|
|
132
|
+
componentCurrency: string | null;
|
|
133
|
+
componentSubtotalAmountCents: number | null;
|
|
134
|
+
componentTaxAmountCents: number | null;
|
|
135
|
+
componentTotalAmountCents: number | null;
|
|
136
|
+
pricingSnapshot: import("@voyantjs/travel-composer").TripComponentPricingSnapshot | null;
|
|
137
|
+
taxLines: import("@voyantjs/travel-composer").TripComponentTaxLineSnapshot[] | null;
|
|
138
|
+
cancellationSnapshot: Record<string, unknown> | null;
|
|
139
|
+
holdToken: string | null;
|
|
140
|
+
holdExpiresAt: Date | null;
|
|
141
|
+
priceExpiresAt: Date | null;
|
|
142
|
+
warningCodes: string[];
|
|
143
|
+
metadata: Record<string, unknown>;
|
|
144
|
+
}>;
|
|
145
|
+
export declare function priceTrip(client: FetchWithValidationOptions, envelopeId: string, input: PriceTripBody): Promise<import("@voyantjs/travel-composer").PriceTripResult>;
|
|
146
|
+
export declare function reserveTrip(client: FetchWithValidationOptions, envelopeId: string, input?: ReserveTripBody): Promise<import("@voyantjs/travel-composer").ReserveTripResult>;
|
|
147
|
+
export declare function startTripCheckout(client: FetchWithValidationOptions, envelopeId: string, input: StartTripCheckoutBody): Promise<import("@voyantjs/travel-composer").StartCheckoutResult>;
|
|
148
|
+
export declare function previewTripCancellation(client: FetchWithValidationOptions, envelopeId: string, input: PreviewTripCancellationBody): Promise<import("@voyantjs/travel-composer").TripCancellationPreviewResult>;
|
|
149
|
+
export declare function cancelTripComponents(client: FetchWithValidationOptions, envelopeId: string, input: CancelTripComponentsBody): Promise<import("@voyantjs/travel-composer").CancelTripComponentsResult>;
|
|
150
|
+
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,4BAA4B,EAC5B,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,2BAA2B,CAAA;AAElC,OAAO,EAAE,KAAK,0BAA0B,EAAuB,MAAM,aAAa,CAAA;AAYlF,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,kBAAkB,CAAA;IAC3B,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AACD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,uBAAuB,EAAE,eAAe,GAAG,aAAa,CAAC,GACzF,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,eAAe,GAAG,aAAa,CAAC,CAAC,CAAA;AACzE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,4BAA4B,EAAE,UAAU,GAAG,UAAU,CAAC,GAC5F,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,UAAU,GAAG,UAAU,CAAC,CAAC,CAAA;AACtE,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAClC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB,CAAA;AACD,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;AAC9D,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAA;AAClE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAA;AAC9E,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAC5C,4BAA4B,EAC5B,YAAY,GAAG,SAAS,CACzB,GACC,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC,CAAA;AACxD,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,yBAAyB,EAAE,YAAY,GAAG,SAAS,CAAC,GAC9F,OAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAC,CAAC,CAAA;AA8BrD,wBAAgB,SAAS,CAAC,MAAM,EAAE,0BAA0B,EAAE,MAAM,GAAE,eAAoB,+DAMzF;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,0BAA0B,EAAE,KAAK,EAAE,cAAc,qDAKnF;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,qDAM7E;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQ5B;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,0BAA0B,EAAE,WAAW,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAO1F;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,0BAA0B,EAClC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQ/B;AAED,wBAAgB,SAAS,CACvB,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,aAAa,gEAQrB;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,MAAM,EAClB,KAAK,GAAE,eAAoB,kEAQ5B;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,qBAAqB,oEAQ7B;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,2BAA2B,8EAQnC;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,wBAAwB,2EAQhC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { fetchWithValidation } from "./client.js";
|
|
3
|
+
import { cancelTripComponentsResponseSchema, previewTripCancellationResponseSchema, priceTripResponseSchema, reserveTripResponseSchema, startTripCheckoutResponseSchema, tripComponentResponseSchema, tripListResponseSchema, tripResponseSchema, } from "./schemas.js";
|
|
4
|
+
function composerPath(client, path) {
|
|
5
|
+
return `/v1/${client.surface ?? "admin"}/travel-composer${path}`;
|
|
6
|
+
}
|
|
7
|
+
function withQuery(path, params = {}) {
|
|
8
|
+
const search = new URLSearchParams();
|
|
9
|
+
if (params.status)
|
|
10
|
+
search.set("status", params.status);
|
|
11
|
+
if (params.search)
|
|
12
|
+
search.set("search", params.search);
|
|
13
|
+
if (params.productId)
|
|
14
|
+
search.set("productId", params.productId);
|
|
15
|
+
if (params.hospitalityId)
|
|
16
|
+
search.set("hospitalityId", params.hospitalityId);
|
|
17
|
+
if (params.cruiseId)
|
|
18
|
+
search.set("cruiseId", params.cruiseId);
|
|
19
|
+
if (params.hasFlight !== undefined)
|
|
20
|
+
search.set("hasFlight", String(params.hasFlight));
|
|
21
|
+
if (params.totalMinCents !== undefined) {
|
|
22
|
+
search.set("totalMinCents", String(params.totalMinCents));
|
|
23
|
+
}
|
|
24
|
+
if (params.totalMaxCents !== undefined) {
|
|
25
|
+
search.set("totalMaxCents", String(params.totalMaxCents));
|
|
26
|
+
}
|
|
27
|
+
if (params.createdFrom)
|
|
28
|
+
search.set("createdFrom", params.createdFrom);
|
|
29
|
+
if (params.createdTo)
|
|
30
|
+
search.set("createdTo", params.createdTo);
|
|
31
|
+
if (params.sortBy)
|
|
32
|
+
search.set("sortBy", params.sortBy);
|
|
33
|
+
if (params.sortDir)
|
|
34
|
+
search.set("sortDir", params.sortDir);
|
|
35
|
+
if (params.limit !== undefined)
|
|
36
|
+
search.set("limit", String(params.limit));
|
|
37
|
+
if (params.offset !== undefined)
|
|
38
|
+
search.set("offset", String(params.offset));
|
|
39
|
+
const suffix = search.toString();
|
|
40
|
+
return suffix ? `${path}?${suffix}` : path;
|
|
41
|
+
}
|
|
42
|
+
export function listTrips(client, params = {}) {
|
|
43
|
+
return fetchWithValidation(composerPath(client, withQuery("/trips", params)), tripListResponseSchema, client);
|
|
44
|
+
}
|
|
45
|
+
export function createTrip(client, input) {
|
|
46
|
+
return fetchWithValidation(composerPath(client, "/trips"), tripResponseSchema, client, {
|
|
47
|
+
method: "POST",
|
|
48
|
+
body: JSON.stringify(input),
|
|
49
|
+
}).then((response) => response.data);
|
|
50
|
+
}
|
|
51
|
+
export function getTrip(client, envelopeId) {
|
|
52
|
+
return fetchWithValidation(composerPath(client, `/trips/${encodeURIComponent(envelopeId)}`), tripResponseSchema, client).then((response) => response.data);
|
|
53
|
+
}
|
|
54
|
+
export function addTripComponent(client, envelopeId, input) {
|
|
55
|
+
return fetchWithValidation(composerPath(client, `/trips/${encodeURIComponent(envelopeId)}/components`), tripComponentResponseSchema, client, { method: "POST", body: JSON.stringify(input) }).then((response) => response.data);
|
|
56
|
+
}
|
|
57
|
+
export function removeTripComponent(client, componentId) {
|
|
58
|
+
return fetchWithValidation(composerPath(client, `/components/${encodeURIComponent(componentId)}`), tripComponentResponseSchema, client, { method: "DELETE" }).then((response) => response.data);
|
|
59
|
+
}
|
|
60
|
+
export function updateTripComponent(client, componentId, input) {
|
|
61
|
+
return fetchWithValidation(composerPath(client, `/components/${encodeURIComponent(componentId)}`), tripComponentResponseSchema, client, { method: "PATCH", body: JSON.stringify(input) }).then((response) => response.data);
|
|
62
|
+
}
|
|
63
|
+
export function priceTrip(client, envelopeId, input) {
|
|
64
|
+
return fetchWithValidation(composerPath(client, `/trips/${encodeURIComponent(envelopeId)}/price`), priceTripResponseSchema, client, { method: "POST", body: JSON.stringify(input) }).then((response) => response.data);
|
|
65
|
+
}
|
|
66
|
+
export function reserveTrip(client, envelopeId, input = {}) {
|
|
67
|
+
return fetchWithValidation(composerPath(client, `/trips/${encodeURIComponent(envelopeId)}/reserve`), reserveTripResponseSchema, client, { method: "POST", body: JSON.stringify(input) }).then((response) => response.data);
|
|
68
|
+
}
|
|
69
|
+
export function startTripCheckout(client, envelopeId, input) {
|
|
70
|
+
return fetchWithValidation(composerPath(client, `/trips/${encodeURIComponent(envelopeId)}/checkout`), startTripCheckoutResponseSchema, client, { method: "POST", body: JSON.stringify(input) }).then((response) => response.data);
|
|
71
|
+
}
|
|
72
|
+
export function previewTripCancellation(client, envelopeId, input) {
|
|
73
|
+
return fetchWithValidation(composerPath(client, `/trips/${encodeURIComponent(envelopeId)}/cancellation-preview`), previewTripCancellationResponseSchema, client, { method: "POST", body: JSON.stringify(input) }).then((response) => response.data);
|
|
74
|
+
}
|
|
75
|
+
export function cancelTripComponents(client, envelopeId, input) {
|
|
76
|
+
return fetchWithValidation(composerPath(client, `/trips/${encodeURIComponent(envelopeId)}/cancel-components`), cancelTripComponentsResponseSchema, client, { method: "POST", body: JSON.stringify(input) }).then((response) => response.data);
|
|
77
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantTravelComposerContext, type VoyantReactContextValue as VoyantTravelComposerContextValue, VoyantReactProvider as VoyantTravelComposerProvider, type VoyantReactProviderProps as VoyantTravelComposerProviderProps, } from "@voyantjs/react";
|
|
2
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,8BAA8B,EACvD,KAAK,uBAAuB,IAAI,gCAAgC,EAChE,mBAAmB,IAAI,4BAA4B,EACnD,KAAK,wBAAwB,IAAI,iCAAiC,GACnE,MAAM,iBAAiB,CAAA"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantTravelComposerContext, VoyantReactProvider as VoyantTravelComposerProvider, } from "@voyantjs/react";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const travelComposerQueryKeys: {
|
|
2
|
+
readonly all: readonly ["voyant", "travel-composer"];
|
|
3
|
+
readonly trips: () => readonly ["voyant", "travel-composer", "trips"];
|
|
4
|
+
readonly tripList: (filters: Record<string, unknown>) => readonly ["voyant", "travel-composer", "trips", "list", Record<string, unknown>];
|
|
5
|
+
readonly trip: (envelopeId: string) => readonly ["voyant", "travel-composer", "trips", "detail", string];
|
|
6
|
+
readonly components: (envelopeId: string) => readonly ["voyant", "travel-composer", "trips", "detail", string, "components"];
|
|
7
|
+
readonly pricing: (envelopeId: string) => readonly ["voyant", "travel-composer", "trips", "detail", string, "pricing"];
|
|
8
|
+
readonly checkout: (envelopeId: string) => readonly ["voyant", "travel-composer", "trips", "detail", string, "checkout"];
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=query-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-keys.d.ts","sourceRoot":"","sources":["../src/query-keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB;;;iCAId,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gCAExB,MAAM;sCAEA,MAAM;mCAET,MAAM;oCAEL,MAAM;CAErB,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const travelComposerQueryKeys = {
|
|
2
|
+
all: ["voyant", "travel-composer"],
|
|
3
|
+
trips: () => [...travelComposerQueryKeys.all, "trips"],
|
|
4
|
+
tripList: (filters) => [...travelComposerQueryKeys.trips(), "list", filters],
|
|
5
|
+
trip: (envelopeId) => [...travelComposerQueryKeys.trips(), "detail", envelopeId],
|
|
6
|
+
components: (envelopeId) => [...travelComposerQueryKeys.trip(envelopeId), "components"],
|
|
7
|
+
pricing: (envelopeId) => [...travelComposerQueryKeys.trip(envelopeId), "pricing"],
|
|
8
|
+
checkout: (envelopeId) => [...travelComposerQueryKeys.trip(envelopeId), "checkout"],
|
|
9
|
+
};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { FetchWithValidationOptions } from "./client.js";
|
|
2
|
+
import { type ListTripsParams } from "./operations.js";
|
|
3
|
+
export declare function listTripsQueryOptions(client: FetchWithValidationOptions, params?: ListTripsParams): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@voyantjs/travel-composer").TripListResult, Error, import("@voyantjs/travel-composer").TripListResult, readonly ["voyant", "travel-composer", "trips", "list", Record<string, unknown>]>, "queryFn"> & {
|
|
4
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<import("@voyantjs/travel-composer").TripListResult, readonly ["voyant", "travel-composer", "trips", "list", Record<string, unknown>], never> | undefined;
|
|
5
|
+
} & {
|
|
6
|
+
queryKey: readonly ["voyant", "travel-composer", "trips", "list", Record<string, unknown>] & {
|
|
7
|
+
[dataTagSymbol]: import("@voyantjs/travel-composer").TripListResult;
|
|
8
|
+
[dataTagErrorSymbol]: Error;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function getTripQueryOptions(client: FetchWithValidationOptions, envelopeId: string): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<import("@voyantjs/travel-composer").Trip, Error, import("@voyantjs/travel-composer").Trip, readonly ["voyant", "travel-composer", "trips", "detail", string]>, "queryFn"> & {
|
|
12
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<import("@voyantjs/travel-composer").Trip, readonly ["voyant", "travel-composer", "trips", "detail", string], never> | undefined;
|
|
13
|
+
} & {
|
|
14
|
+
queryKey: readonly ["voyant", "travel-composer", "trips", "detail", string] & {
|
|
15
|
+
[dataTagSymbol]: import("@voyantjs/travel-composer").Trip;
|
|
16
|
+
[dataTagErrorSymbol]: Error;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function getTripComponentsQueryOptions(client: FetchWithValidationOptions, envelopeId: string): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
20
|
+
id: string;
|
|
21
|
+
status: "draft" | "priced" | "checkout_started" | "booked" | "failed" | "cancelled" | "unavailable" | "held" | "removed";
|
|
22
|
+
title: string | null;
|
|
23
|
+
description: string | null;
|
|
24
|
+
bookingGroupId: string | null;
|
|
25
|
+
orderId: string | null;
|
|
26
|
+
paymentSessionId: string | null;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
updatedAt: Date;
|
|
29
|
+
envelopeId: string;
|
|
30
|
+
sequence: number;
|
|
31
|
+
kind: "catalog_booking" | "manual_placeholder" | "flight_placeholder" | "flight_order" | "external_order";
|
|
32
|
+
entityModule: string | null;
|
|
33
|
+
entityId: string | null;
|
|
34
|
+
sourceKind: string | null;
|
|
35
|
+
sourceConnectionId: string | null;
|
|
36
|
+
sourceRef: string | null;
|
|
37
|
+
bookingDraftId: string | null;
|
|
38
|
+
catalogQuoteId: string | null;
|
|
39
|
+
bookingId: string | null;
|
|
40
|
+
providerRef: string | null;
|
|
41
|
+
supplierRef: string | null;
|
|
42
|
+
componentCurrency: string | null;
|
|
43
|
+
componentSubtotalAmountCents: number | null;
|
|
44
|
+
componentTaxAmountCents: number | null;
|
|
45
|
+
componentTotalAmountCents: number | null;
|
|
46
|
+
pricingSnapshot: import("@voyantjs/travel-composer").TripComponentPricingSnapshot | null;
|
|
47
|
+
taxLines: import("@voyantjs/travel-composer").TripComponentTaxLineSnapshot[] | null;
|
|
48
|
+
cancellationSnapshot: Record<string, unknown> | null;
|
|
49
|
+
holdToken: string | null;
|
|
50
|
+
holdExpiresAt: Date | null;
|
|
51
|
+
priceExpiresAt: Date | null;
|
|
52
|
+
warningCodes: string[];
|
|
53
|
+
metadata: Record<string, unknown>;
|
|
54
|
+
}[], Error, {
|
|
55
|
+
id: string;
|
|
56
|
+
status: "draft" | "priced" | "checkout_started" | "booked" | "failed" | "cancelled" | "unavailable" | "held" | "removed";
|
|
57
|
+
title: string | null;
|
|
58
|
+
description: string | null;
|
|
59
|
+
bookingGroupId: string | null;
|
|
60
|
+
orderId: string | null;
|
|
61
|
+
paymentSessionId: string | null;
|
|
62
|
+
createdAt: Date;
|
|
63
|
+
updatedAt: Date;
|
|
64
|
+
envelopeId: string;
|
|
65
|
+
sequence: number;
|
|
66
|
+
kind: "catalog_booking" | "manual_placeholder" | "flight_placeholder" | "flight_order" | "external_order";
|
|
67
|
+
entityModule: string | null;
|
|
68
|
+
entityId: string | null;
|
|
69
|
+
sourceKind: string | null;
|
|
70
|
+
sourceConnectionId: string | null;
|
|
71
|
+
sourceRef: string | null;
|
|
72
|
+
bookingDraftId: string | null;
|
|
73
|
+
catalogQuoteId: string | null;
|
|
74
|
+
bookingId: string | null;
|
|
75
|
+
providerRef: string | null;
|
|
76
|
+
supplierRef: string | null;
|
|
77
|
+
componentCurrency: string | null;
|
|
78
|
+
componentSubtotalAmountCents: number | null;
|
|
79
|
+
componentTaxAmountCents: number | null;
|
|
80
|
+
componentTotalAmountCents: number | null;
|
|
81
|
+
pricingSnapshot: import("@voyantjs/travel-composer").TripComponentPricingSnapshot | null;
|
|
82
|
+
taxLines: import("@voyantjs/travel-composer").TripComponentTaxLineSnapshot[] | null;
|
|
83
|
+
cancellationSnapshot: Record<string, unknown> | null;
|
|
84
|
+
holdToken: string | null;
|
|
85
|
+
holdExpiresAt: Date | null;
|
|
86
|
+
priceExpiresAt: Date | null;
|
|
87
|
+
warningCodes: string[];
|
|
88
|
+
metadata: Record<string, unknown>;
|
|
89
|
+
}[], readonly ["voyant", "travel-composer", "trips", "detail", string, "components"]>, "queryFn"> & {
|
|
90
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
91
|
+
id: string;
|
|
92
|
+
status: "draft" | "priced" | "checkout_started" | "booked" | "failed" | "cancelled" | "unavailable" | "held" | "removed";
|
|
93
|
+
title: string | null;
|
|
94
|
+
description: string | null;
|
|
95
|
+
bookingGroupId: string | null;
|
|
96
|
+
orderId: string | null;
|
|
97
|
+
paymentSessionId: string | null;
|
|
98
|
+
createdAt: Date;
|
|
99
|
+
updatedAt: Date;
|
|
100
|
+
envelopeId: string;
|
|
101
|
+
sequence: number;
|
|
102
|
+
kind: "catalog_booking" | "manual_placeholder" | "flight_placeholder" | "flight_order" | "external_order";
|
|
103
|
+
entityModule: string | null;
|
|
104
|
+
entityId: string | null;
|
|
105
|
+
sourceKind: string | null;
|
|
106
|
+
sourceConnectionId: string | null;
|
|
107
|
+
sourceRef: string | null;
|
|
108
|
+
bookingDraftId: string | null;
|
|
109
|
+
catalogQuoteId: string | null;
|
|
110
|
+
bookingId: string | null;
|
|
111
|
+
providerRef: string | null;
|
|
112
|
+
supplierRef: string | null;
|
|
113
|
+
componentCurrency: string | null;
|
|
114
|
+
componentSubtotalAmountCents: number | null;
|
|
115
|
+
componentTaxAmountCents: number | null;
|
|
116
|
+
componentTotalAmountCents: number | null;
|
|
117
|
+
pricingSnapshot: import("@voyantjs/travel-composer").TripComponentPricingSnapshot | null;
|
|
118
|
+
taxLines: import("@voyantjs/travel-composer").TripComponentTaxLineSnapshot[] | null;
|
|
119
|
+
cancellationSnapshot: Record<string, unknown> | null;
|
|
120
|
+
holdToken: string | null;
|
|
121
|
+
holdExpiresAt: Date | null;
|
|
122
|
+
priceExpiresAt: Date | null;
|
|
123
|
+
warningCodes: string[];
|
|
124
|
+
metadata: Record<string, unknown>;
|
|
125
|
+
}[], readonly ["voyant", "travel-composer", "trips", "detail", string, "components"], never> | undefined;
|
|
126
|
+
} & {
|
|
127
|
+
queryKey: readonly ["voyant", "travel-composer", "trips", "detail", string, "components"] & {
|
|
128
|
+
[dataTagSymbol]: {
|
|
129
|
+
id: string;
|
|
130
|
+
status: "draft" | "priced" | "checkout_started" | "booked" | "failed" | "cancelled" | "unavailable" | "held" | "removed";
|
|
131
|
+
title: string | null;
|
|
132
|
+
description: string | null;
|
|
133
|
+
bookingGroupId: string | null;
|
|
134
|
+
orderId: string | null;
|
|
135
|
+
paymentSessionId: string | null;
|
|
136
|
+
createdAt: Date;
|
|
137
|
+
updatedAt: Date;
|
|
138
|
+
envelopeId: string;
|
|
139
|
+
sequence: number;
|
|
140
|
+
kind: "catalog_booking" | "manual_placeholder" | "flight_placeholder" | "flight_order" | "external_order";
|
|
141
|
+
entityModule: string | null;
|
|
142
|
+
entityId: string | null;
|
|
143
|
+
sourceKind: string | null;
|
|
144
|
+
sourceConnectionId: string | null;
|
|
145
|
+
sourceRef: string | null;
|
|
146
|
+
bookingDraftId: string | null;
|
|
147
|
+
catalogQuoteId: string | null;
|
|
148
|
+
bookingId: string | null;
|
|
149
|
+
providerRef: string | null;
|
|
150
|
+
supplierRef: string | null;
|
|
151
|
+
componentCurrency: string | null;
|
|
152
|
+
componentSubtotalAmountCents: number | null;
|
|
153
|
+
componentTaxAmountCents: number | null;
|
|
154
|
+
componentTotalAmountCents: number | null;
|
|
155
|
+
pricingSnapshot: import("@voyantjs/travel-composer").TripComponentPricingSnapshot | null;
|
|
156
|
+
taxLines: import("@voyantjs/travel-composer").TripComponentTaxLineSnapshot[] | null;
|
|
157
|
+
cancellationSnapshot: Record<string, unknown> | null;
|
|
158
|
+
holdToken: string | null;
|
|
159
|
+
holdExpiresAt: Date | null;
|
|
160
|
+
priceExpiresAt: Date | null;
|
|
161
|
+
warningCodes: string[];
|
|
162
|
+
metadata: Record<string, unknown>;
|
|
163
|
+
}[];
|
|
164
|
+
[dataTagErrorSymbol]: Error;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
//# sourceMappingURL=query-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-options.d.ts","sourceRoot":"","sources":["../src/query-options.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAW,KAAK,eAAe,EAAa,MAAM,iBAAiB,CAAA;AAG1E,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,0BAA0B,EAClC,MAAM,GAAE,eAAoB;;;;;;;EAM7B;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM;;;;;;;EAKzF;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,0BAA0B,EAClC,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMnB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
+
import { getTrip, listTrips } from "./operations.js";
|
|
4
|
+
import { travelComposerQueryKeys } from "./query-keys.js";
|
|
5
|
+
export function listTripsQueryOptions(client, params = {}) {
|
|
6
|
+
return queryOptions({
|
|
7
|
+
queryKey: travelComposerQueryKeys.tripList(params),
|
|
8
|
+
queryFn: () => listTrips(client, params),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function getTripQueryOptions(client, envelopeId) {
|
|
12
|
+
return queryOptions({
|
|
13
|
+
queryKey: travelComposerQueryKeys.trip(envelopeId),
|
|
14
|
+
queryFn: () => getTrip(client, envelopeId),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export function getTripComponentsQueryOptions(client, envelopeId) {
|
|
18
|
+
return queryOptions({
|
|
19
|
+
queryKey: travelComposerQueryKeys.components(envelopeId),
|
|
20
|
+
queryFn: () => getTrip(client, envelopeId).then((trip) => trip.components),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CancelTripComponentsResult, PriceTripResult, ReserveTripResult, StartCheckoutResult, Trip, TripCancellationPreviewResult, TripComponent, TripEnvelope, TripListResult } from "@voyantjs/travel-composer";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const singleEnvelope: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
|
|
4
|
+
data: T;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const tripResponseSchema: z.ZodType<{
|
|
7
|
+
data: Trip;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const tripListResponseSchema: z.ZodType<TripListResult>;
|
|
10
|
+
export declare const tripEnvelopeResponseSchema: z.ZodType<{
|
|
11
|
+
data: TripEnvelope;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const tripComponentResponseSchema: z.ZodType<{
|
|
14
|
+
data: TripComponent;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const tripComponentsResponseSchema: z.ZodType<{
|
|
17
|
+
data: Trip["components"];
|
|
18
|
+
}>;
|
|
19
|
+
export declare const priceTripResponseSchema: z.ZodType<{
|
|
20
|
+
data: PriceTripResult;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const reserveTripResponseSchema: z.ZodType<{
|
|
23
|
+
data: ReserveTripResult;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const startTripCheckoutResponseSchema: z.ZodType<{
|
|
26
|
+
data: StartCheckoutResult;
|
|
27
|
+
}>;
|
|
28
|
+
export declare const previewTripCancellationResponseSchema: z.ZodType<{
|
|
29
|
+
data: TripCancellationPreviewResult;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const cancelTripComponentsResponseSchema: z.ZodType<{
|
|
32
|
+
data: CancelTripComponentsResult;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,IAAI,EACJ,6BAA6B,EAC7B,aAAa,EACb,YAAY,EACZ,cAAc,EACf,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;;iBAA6B,CAAA;AAI3F,eAAO,MAAM,kBAAkB,EAAkC,CAAC,CAAC,OAAO,CAAC;IACzE,IAAI,EAAE,IAAI,CAAA;CACX,CAAC,CAAA;AACF,eAAO,MAAM,sBAAsB,EAAkB,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;AAC9E,eAAO,MAAM,0BAA0B,EAAkC,CAAC,CAAC,OAAO,CAAC;IACjF,IAAI,EAAE,YAAY,CAAA;CACnB,CAAC,CAAA;AACF,eAAO,MAAM,2BAA2B,EAAkC,CAAC,CAAC,OAAO,CAAC;IAClF,IAAI,EAAE,aAAa,CAAA;CACpB,CAAC,CAAA;AACF,eAAO,MAAM,4BAA4B,EAAkC,CAAC,CAAC,OAAO,CAAC;IACnF,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;CACzB,CAAC,CAAA;AACF,eAAO,MAAM,uBAAuB,EAAkC,CAAC,CAAC,OAAO,CAAC;IAC9E,IAAI,EAAE,eAAe,CAAA;CACtB,CAAC,CAAA;AACF,eAAO,MAAM,yBAAyB,EAAkC,CAAC,CAAC,OAAO,CAAC;IAChF,IAAI,EAAE,iBAAiB,CAAA;CACxB,CAAC,CAAA;AACF,eAAO,MAAM,+BAA+B,EAAkC,CAAC,CAAC,OAAO,CAAC;IACtF,IAAI,EAAE,mBAAmB,CAAA;CAC1B,CAAC,CAAA;AACF,eAAO,MAAM,qCAAqC,EAAkC,CAAC,CAAC,OAAO,CAAC;IAC5F,IAAI,EAAE,6BAA6B,CAAA;CACpC,CAAC,CAAA;AACF,eAAO,MAAM,kCAAkC,EAAkC,CAAC,CAAC,OAAO,CAAC;IACzF,IAAI,EAAE,0BAA0B,CAAA;CACjC,CAAC,CAAA"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const singleEnvelope = (item) => z.object({ data: item });
|
|
3
|
+
const unknownData = z.unknown();
|
|
4
|
+
export const tripResponseSchema = singleEnvelope(unknownData);
|
|
5
|
+
export const tripListResponseSchema = unknownData;
|
|
6
|
+
export const tripEnvelopeResponseSchema = singleEnvelope(unknownData);
|
|
7
|
+
export const tripComponentResponseSchema = singleEnvelope(unknownData);
|
|
8
|
+
export const tripComponentsResponseSchema = singleEnvelope(unknownData);
|
|
9
|
+
export const priceTripResponseSchema = singleEnvelope(unknownData);
|
|
10
|
+
export const reserveTripResponseSchema = singleEnvelope(unknownData);
|
|
11
|
+
export const startTripCheckoutResponseSchema = singleEnvelope(unknownData);
|
|
12
|
+
export const previewTripCancellationResponseSchema = singleEnvelope(unknownData);
|
|
13
|
+
export const cancelTripComponentsResponseSchema = singleEnvelope(unknownData);
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/travel-composer-react",
|
|
3
|
+
"version": "0.55.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/voyantjs/voyant.git",
|
|
8
|
+
"directory": "packages/travel-composer-react"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./src/index.ts",
|
|
14
|
+
"./provider": "./src/provider.tsx",
|
|
15
|
+
"./hooks": "./src/hooks/index.ts",
|
|
16
|
+
"./client": "./src/client.ts",
|
|
17
|
+
"./query-keys": "./src/query-keys.ts"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.json",
|
|
21
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
22
|
+
"prepack": "pnpm run build",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"lint": "biome check src/ tests/",
|
|
25
|
+
"test": "vitest run"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@tanstack/react-query": "^5.0.0",
|
|
29
|
+
"@voyantjs/travel-composer": "workspace:*",
|
|
30
|
+
"react": "^19.0.0",
|
|
31
|
+
"react-dom": "^19.0.0",
|
|
32
|
+
"zod": "^4.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@tanstack/react-query": "^5.96.2",
|
|
36
|
+
"@types/react": "^19.2.14",
|
|
37
|
+
"@types/react-dom": "^19.2.3",
|
|
38
|
+
"@voyantjs/react": "workspace:*",
|
|
39
|
+
"@voyantjs/travel-composer": "workspace:*",
|
|
40
|
+
"@voyantjs/voyant-typescript-config": "workspace:*",
|
|
41
|
+
"react": "^19.2.4",
|
|
42
|
+
"react-dom": "^19.2.4",
|
|
43
|
+
"typescript": "^6.0.2",
|
|
44
|
+
"vitest": "^4.1.2",
|
|
45
|
+
"zod": "^4.3.6"
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@voyantjs/react": "workspace:*"
|
|
49
|
+
},
|
|
50
|
+
"files": [
|
|
51
|
+
"dist"
|
|
52
|
+
],
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public",
|
|
55
|
+
"exports": {
|
|
56
|
+
".": {
|
|
57
|
+
"types": "./dist/index.d.ts",
|
|
58
|
+
"import": "./dist/index.js",
|
|
59
|
+
"default": "./dist/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./provider": {
|
|
62
|
+
"types": "./dist/provider.d.ts",
|
|
63
|
+
"import": "./dist/provider.js",
|
|
64
|
+
"default": "./dist/provider.js"
|
|
65
|
+
},
|
|
66
|
+
"./hooks": {
|
|
67
|
+
"types": "./dist/hooks/index.d.ts",
|
|
68
|
+
"import": "./dist/hooks/index.js",
|
|
69
|
+
"default": "./dist/hooks/index.js"
|
|
70
|
+
},
|
|
71
|
+
"./client": {
|
|
72
|
+
"types": "./dist/client.d.ts",
|
|
73
|
+
"import": "./dist/client.js",
|
|
74
|
+
"default": "./dist/client.js"
|
|
75
|
+
},
|
|
76
|
+
"./query-keys": {
|
|
77
|
+
"types": "./dist/query-keys.d.ts",
|
|
78
|
+
"import": "./dist/query-keys.js",
|
|
79
|
+
"default": "./dist/query-keys.js"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"main": "./dist/index.js",
|
|
83
|
+
"types": "./dist/index.d.ts"
|
|
84
|
+
}
|
|
85
|
+
}
|