@voyantjs/bookings-react 0.2.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 (38) hide show
  1. package/README.md +1 -0
  2. package/dist/client.d.ts +14 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +59 -0
  5. package/dist/hooks/index.d.ts +7 -0
  6. package/dist/hooks/index.d.ts.map +1 -0
  7. package/dist/hooks/index.js +6 -0
  8. package/dist/hooks/use-booking-mutation.d.ts +57 -0
  9. package/dist/hooks/use-booking-mutation.d.ts.map +1 -0
  10. package/dist/hooks/use-booking-mutation.js +39 -0
  11. package/dist/hooks/use-booking-status-mutation.d.ts +23 -0
  12. package/dist/hooks/use-booking-status-mutation.d.ts.map +1 -0
  13. package/dist/hooks/use-booking-status-mutation.js +21 -0
  14. package/dist/hooks/use-booking.d.ts +23 -0
  15. package/dist/hooks/use-booking.d.ts.map +1 -0
  16. package/dist/hooks/use-booking.js +15 -0
  17. package/dist/hooks/use-bookings.d.ts +27 -0
  18. package/dist/hooks/use-bookings.d.ts.map +1 -0
  19. package/dist/hooks/use-bookings.js +30 -0
  20. package/dist/hooks/use-passenger-mutation.d.ts +42 -0
  21. package/dist/hooks/use-passenger-mutation.d.ts.map +1 -0
  22. package/dist/hooks/use-passenger-mutation.js +42 -0
  23. package/dist/hooks/use-passengers.d.ts +18 -0
  24. package/dist/hooks/use-passengers.d.ts.map +1 -0
  25. package/dist/hooks/use-passengers.js +18 -0
  26. package/dist/index.d.ts +6 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +5 -0
  29. package/dist/provider.d.ts +14 -0
  30. package/dist/provider.d.ts.map +1 -0
  31. package/dist/provider.js +16 -0
  32. package/dist/query-keys.d.ts +17 -0
  33. package/dist/query-keys.d.ts.map +1 -0
  34. package/dist/query-keys.js +10 -0
  35. package/dist/schemas.d.ts +221 -0
  36. package/dist/schemas.d.ts.map +1 -0
  37. package/dist/schemas.js +90 -0
  38. package/package.json +75 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ `@voyantjs/bookings-react` provides React Query hooks and provider utilities for Voyant bookings.
@@ -0,0 +1,14 @@
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 declare function fetchWithValidation<TOut>(path: string, schema: z.ZodType<TOut>, options: FetchWithValidationOptions, init?: RequestInit): Promise<TOut>;
14
+ //# 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;AAaD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;CACvB;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,CAgCf"}
package/dist/client.js ADDED
@@ -0,0 +1,59 @@
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
+ }
37
+ const body = await safeJson(response);
38
+ const parsed = schema.safeParse(body);
39
+ if (!parsed.success) {
40
+ throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
41
+ }
42
+ return parsed.data;
43
+ }
44
+ async function safeJson(response) {
45
+ const text = await response.text();
46
+ if (!text)
47
+ return undefined;
48
+ try {
49
+ return JSON.parse(text);
50
+ }
51
+ catch {
52
+ return text;
53
+ }
54
+ }
55
+ function joinUrl(baseUrl, path) {
56
+ const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
57
+ const trimmedPath = path.startsWith("/") ? path : `/${path}`;
58
+ return `${trimmedBase}${trimmedPath}`;
59
+ }
@@ -0,0 +1,7 @@
1
+ export { type UseBookingOptions, useBooking } from "./use-booking.js";
2
+ export { type CreateBookingInput, type UpdateBookingInput, useBookingMutation, } from "./use-booking-mutation.js";
3
+ export { type UpdateBookingStatusInput, useBookingStatusMutation, } from "./use-booking-status-mutation.js";
4
+ export { type UseBookingsOptions, useBookings } from "./use-bookings.js";
5
+ export { type CreatePassengerInput, type UpdatePassengerInput, usePassengerMutation, } from "./use-passenger-mutation.js";
6
+ export { type UsePassengersOptions, usePassengers } from "./use-passengers.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,KAAK,iBAAiB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,kBAAkB,GACnB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,KAAK,wBAAwB,EAC7B,wBAAwB,GACzB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,oBAAoB,GACrB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,6 @@
1
+ export { useBooking } from "./use-booking.js";
2
+ export { useBookingMutation, } from "./use-booking-mutation.js";
3
+ export { useBookingStatusMutation, } from "./use-booking-status-mutation.js";
4
+ export { useBookings } from "./use-bookings.js";
5
+ export { usePassengerMutation, } from "./use-passenger-mutation.js";
6
+ export { usePassengers } from "./use-passengers.js";
@@ -0,0 +1,57 @@
1
+ export interface CreateBookingInput {
2
+ bookingNumber: string;
3
+ status?: "draft" | "confirmed" | "in_progress" | "completed" | "cancelled";
4
+ personId?: string | null;
5
+ organizationId?: string | null;
6
+ sellCurrency: string;
7
+ sellAmountCents?: number | null;
8
+ costAmountCents?: number | null;
9
+ startDate?: string | null;
10
+ endDate?: string | null;
11
+ pax?: number | null;
12
+ internalNotes?: string | null;
13
+ }
14
+ export type UpdateBookingInput = Partial<CreateBookingInput>;
15
+ export declare function useBookingMutation(): {
16
+ create: import("@tanstack/react-query").UseMutationResult<{
17
+ id: string;
18
+ bookingNumber: string;
19
+ status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
20
+ personId: string | null;
21
+ organizationId: string | null;
22
+ sellCurrency: string;
23
+ sellAmountCents: number | null;
24
+ costAmountCents: number | null;
25
+ marginPercent: number | null;
26
+ startDate: string | null;
27
+ endDate: string | null;
28
+ pax: number | null;
29
+ internalNotes: string | null;
30
+ createdAt: string;
31
+ updatedAt: string;
32
+ }, Error, CreateBookingInput, unknown>;
33
+ update: import("@tanstack/react-query").UseMutationResult<{
34
+ id: string;
35
+ bookingNumber: string;
36
+ status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
37
+ personId: string | null;
38
+ organizationId: string | null;
39
+ sellCurrency: string;
40
+ sellAmountCents: number | null;
41
+ costAmountCents: number | null;
42
+ marginPercent: number | null;
43
+ startDate: string | null;
44
+ endDate: string | null;
45
+ pax: number | null;
46
+ internalNotes: string | null;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ }, Error, {
50
+ id: string;
51
+ input: UpdateBookingInput;
52
+ }, unknown>;
53
+ remove: import("@tanstack/react-query").UseMutationResult<{
54
+ success: boolean;
55
+ }, Error, string, unknown>;
56
+ };
57
+ //# sourceMappingURL=use-booking-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-booking-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,GAAG,WAAW,GAAG,aAAa,GAAG,WAAW,GAAG,WAAW,CAAA;IAC1E,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,YAAY,EAAE,MAAM,CAAA;IACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;AAE5D,wBAAgB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAoBU,MAAM;eAAS,kBAAkB;;;;;EAgC5E"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantBookingsContext } from "../provider.js";
5
+ import { bookingsQueryKeys } from "../query-keys.js";
6
+ import { bookingSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useBookingMutation() {
8
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/bookings", bookingSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: () => {
16
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.bookings() });
17
+ },
18
+ });
19
+ const update = useMutation({
20
+ mutationFn: async ({ id, input }) => {
21
+ const { data } = await fetchWithValidation(`/v1/bookings/${id}`, bookingSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
22
+ return data;
23
+ },
24
+ onSuccess: (data) => {
25
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.bookings() });
26
+ queryClient.setQueryData(bookingsQueryKeys.booking(data.id), { data });
27
+ },
28
+ });
29
+ const remove = useMutation({
30
+ mutationFn: async (id) => fetchWithValidation(`/v1/bookings/${id}`, successEnvelope, { baseUrl, fetcher }, {
31
+ method: "DELETE",
32
+ }),
33
+ onSuccess: (_data, id) => {
34
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.bookings() });
35
+ queryClient.removeQueries({ queryKey: bookingsQueryKeys.booking(id) });
36
+ },
37
+ });
38
+ return { create, update, remove };
39
+ }
@@ -0,0 +1,23 @@
1
+ import { type BookingRecord } from "../schemas.js";
2
+ export interface UpdateBookingStatusInput {
3
+ status: BookingRecord["status"];
4
+ note?: string | null;
5
+ }
6
+ export declare function useBookingStatusMutation(bookingId: string): import("@tanstack/react-query").UseMutationResult<{
7
+ id: string;
8
+ bookingNumber: string;
9
+ status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
10
+ personId: string | null;
11
+ organizationId: string | null;
12
+ sellCurrency: string;
13
+ sellAmountCents: number | null;
14
+ costAmountCents: number | null;
15
+ marginPercent: number | null;
16
+ startDate: string | null;
17
+ endDate: string | null;
18
+ pax: number | null;
19
+ internalNotes: string | null;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ }, Error, UpdateBookingStatusInput, unknown>;
23
+ //# sourceMappingURL=use-booking-status-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-booking-status-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-status-mutation.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,aAAa,EAAyB,MAAM,eAAe,CAAA;AAEzE,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;6CAoBzD"}
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantBookingsContext } from "../provider.js";
5
+ import { bookingsQueryKeys } from "../query-keys.js";
6
+ import { bookingSingleResponse } from "../schemas.js";
7
+ export function useBookingStatusMutation(bookingId) {
8
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
9
+ const queryClient = useQueryClient();
10
+ return useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/status`, bookingSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.bookings() });
17
+ queryClient.setQueryData(bookingsQueryKeys.booking(bookingId), { data });
18
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.activity(bookingId) });
19
+ },
20
+ });
21
+ }
@@ -0,0 +1,23 @@
1
+ export interface UseBookingOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useBooking(id: string | null | undefined, options?: UseBookingOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ id: string;
7
+ bookingNumber: string;
8
+ status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
9
+ personId: string | null;
10
+ organizationId: string | null;
11
+ sellCurrency: string;
12
+ sellAmountCents: number | null;
13
+ costAmountCents: number | null;
14
+ marginPercent: number | null;
15
+ startDate: string | null;
16
+ endDate: string | null;
17
+ pax: number | null;
18
+ internalNotes: string | null;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ };
22
+ }, Error>;
23
+ //# sourceMappingURL=use-booking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-booking.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,iBAAsB;;;;;;;;;;;;;;;;;;UAUxF"}
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantBookingsContext } from "../provider.js";
5
+ import { bookingsQueryKeys } from "../query-keys.js";
6
+ import { bookingSingleResponse } from "../schemas.js";
7
+ export function useBooking(id, options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
9
+ const { enabled = true } = options;
10
+ return useQuery({
11
+ queryKey: bookingsQueryKeys.booking(id ?? ""),
12
+ queryFn: () => fetchWithValidation(`/v1/bookings/${id}`, bookingSingleResponse, { baseUrl, fetcher }),
13
+ enabled: enabled && Boolean(id),
14
+ });
15
+ }
@@ -0,0 +1,27 @@
1
+ import { type BookingsListFilters } from "../query-keys.js";
2
+ export interface UseBookingsOptions extends BookingsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useBookings(options?: UseBookingsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ bookingNumber: string;
9
+ status: "draft" | "on_hold" | "confirmed" | "in_progress" | "completed" | "expired" | "cancelled";
10
+ personId: string | null;
11
+ organizationId: string | null;
12
+ sellCurrency: string;
13
+ sellAmountCents: number | null;
14
+ costAmountCents: number | null;
15
+ marginPercent: number | null;
16
+ startDate: string | null;
17
+ endDate: string | null;
18
+ pax: number | null;
19
+ internalNotes: string | null;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ }[];
23
+ total: number;
24
+ limit: number;
25
+ offset: number;
26
+ }, Error>;
27
+ //# sourceMappingURL=use-bookings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-bookings.d.ts","sourceRoot":"","sources":["../../src/hooks/use-bookings.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,kBAAkB,CAAA;AAG9E,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;;;;;;;;;;;;;;UAoB3D"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantBookingsContext } from "../provider.js";
5
+ import { bookingsQueryKeys } from "../query-keys.js";
6
+ import { bookingListResponse } from "../schemas.js";
7
+ export function useBookings(options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
9
+ const { enabled = true, ...filters } = options;
10
+ return useQuery({
11
+ queryKey: bookingsQueryKeys.bookingsList(filters),
12
+ queryFn: () => {
13
+ const params = new URLSearchParams();
14
+ if (filters.status)
15
+ params.set("status", filters.status);
16
+ if (filters.search)
17
+ params.set("search", filters.search);
18
+ if (filters.limit !== undefined)
19
+ params.set("limit", String(filters.limit));
20
+ if (filters.offset !== undefined)
21
+ params.set("offset", String(filters.offset));
22
+ const qs = params.toString();
23
+ return fetchWithValidation(`/v1/bookings${qs ? `?${qs}` : ""}`, bookingListResponse, {
24
+ baseUrl,
25
+ fetcher,
26
+ });
27
+ },
28
+ enabled,
29
+ });
30
+ }
@@ -0,0 +1,42 @@
1
+ export interface CreatePassengerInput {
2
+ firstName: string;
3
+ lastName: string;
4
+ email?: string | null;
5
+ phone?: string | null;
6
+ specialRequests?: string | null;
7
+ isLeadPassenger?: boolean | null;
8
+ }
9
+ export type UpdatePassengerInput = Partial<CreatePassengerInput>;
10
+ export declare function usePassengerMutation(bookingId: string): {
11
+ create: import("@tanstack/react-query").UseMutationResult<{
12
+ id: string;
13
+ bookingId: string;
14
+ firstName: string;
15
+ lastName: string;
16
+ email: string | null;
17
+ phone: string | null;
18
+ specialRequests: string | null;
19
+ createdAt: string;
20
+ isLeadPassenger?: boolean | null | undefined;
21
+ updatedAt?: string | undefined;
22
+ }, Error, CreatePassengerInput, unknown>;
23
+ update: import("@tanstack/react-query").UseMutationResult<{
24
+ id: string;
25
+ bookingId: string;
26
+ firstName: string;
27
+ lastName: string;
28
+ email: string | null;
29
+ phone: string | null;
30
+ specialRequests: string | null;
31
+ createdAt: string;
32
+ isLeadPassenger?: boolean | null | undefined;
33
+ updatedAt?: string | undefined;
34
+ }, Error, {
35
+ id: string;
36
+ input: UpdatePassengerInput;
37
+ }, unknown>;
38
+ remove: import("@tanstack/react-query").UseMutationResult<{
39
+ success: boolean;
40
+ }, Error, string, unknown>;
41
+ };
42
+ //# sourceMappingURL=use-passenger-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-passenger-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-passenger-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAEhE,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;YAuBV,MAAM;eAAS,oBAAoB;;;;;EAgC9E"}
@@ -0,0 +1,42 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantBookingsContext } from "../provider.js";
5
+ import { bookingsQueryKeys } from "../query-keys.js";
6
+ import { bookingPassengersResponse, bookingSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function usePassengerMutation(bookingId) {
8
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/passengers`, bookingSingleResponse.extend({
13
+ data: bookingPassengersResponse.shape.data.element,
14
+ }), { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
15
+ return data;
16
+ },
17
+ onSuccess: () => {
18
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.passengers(bookingId) });
19
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.activity(bookingId) });
20
+ },
21
+ });
22
+ const update = useMutation({
23
+ mutationFn: async ({ id, input }) => {
24
+ const { data } = await fetchWithValidation(`/v1/bookings/${bookingId}/passengers/${id}`, bookingSingleResponse.extend({
25
+ data: bookingPassengersResponse.shape.data.element,
26
+ }), { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
27
+ return data;
28
+ },
29
+ onSuccess: () => {
30
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.passengers(bookingId) });
31
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.activity(bookingId) });
32
+ },
33
+ });
34
+ const remove = useMutation({
35
+ mutationFn: async (passengerId) => fetchWithValidation(`/v1/bookings/${bookingId}/passengers/${passengerId}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
36
+ onSuccess: () => {
37
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.passengers(bookingId) });
38
+ void queryClient.invalidateQueries({ queryKey: bookingsQueryKeys.activity(bookingId) });
39
+ },
40
+ });
41
+ return { create, update, remove };
42
+ }
@@ -0,0 +1,18 @@
1
+ export interface UsePassengersOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function usePassengers(bookingId: string | null | undefined, options?: UsePassengersOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ id: string;
7
+ bookingId: string;
8
+ firstName: string;
9
+ lastName: string;
10
+ email: string | null;
11
+ phone: string | null;
12
+ specialRequests: string | null;
13
+ createdAt: string;
14
+ isLeadPassenger?: boolean | null | undefined;
15
+ updatedAt?: string | undefined;
16
+ }[];
17
+ }, Error>;
18
+ //# sourceMappingURL=use-passengers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-passengers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-passengers.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,oBAAyB;;;;;;;;;;;;;UAcnC"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantBookingsContext } from "../provider.js";
5
+ import { bookingsQueryKeys } from "../query-keys.js";
6
+ import { bookingPassengersResponse } from "../schemas.js";
7
+ export function usePassengers(bookingId, options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantBookingsContext();
9
+ const { enabled = true } = options;
10
+ return useQuery({
11
+ queryKey: bookingsQueryKeys.passengers(bookingId ?? ""),
12
+ queryFn: () => fetchWithValidation(`/v1/bookings/${bookingId}/passengers`, bookingPassengersResponse, {
13
+ baseUrl,
14
+ fetcher,
15
+ }),
16
+ enabled: enabled && Boolean(bookingId),
17
+ });
18
+ }
@@ -0,0 +1,6 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantBookingsContext, type VoyantBookingsContextValue, VoyantBookingsProvider, type VoyantBookingsProviderProps, } from "./provider.js";
4
+ export { bookingsQueryKeys } from "./query-keys.js";
5
+ export * from "./schemas.js";
6
+ //# 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,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,wBAAwB,EACxB,KAAK,0BAA0B,EAC/B,sBAAsB,EACtB,KAAK,2BAA2B,GACjC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnD,cAAc,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantBookingsContext, VoyantBookingsProvider, } from "./provider.js";
4
+ export { bookingsQueryKeys } from "./query-keys.js";
5
+ export * from "./schemas.js";
@@ -0,0 +1,14 @@
1
+ import { type ReactNode } from "react";
2
+ import { type VoyantFetcher } from "./client.js";
3
+ export interface VoyantBookingsContextValue {
4
+ baseUrl: string;
5
+ fetcher: VoyantFetcher;
6
+ }
7
+ export interface VoyantBookingsProviderProps {
8
+ baseUrl: string;
9
+ fetcher?: VoyantFetcher;
10
+ children: ReactNode;
11
+ }
12
+ export declare function VoyantBookingsProvider({ baseUrl, fetcher, children, }: VoyantBookingsProviderProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function useVoyantBookingsContext(): VoyantBookingsContextValue;
14
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAA;AAE1E,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhE,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;CACvB;AAID,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,2BAA2B,2CAO7B;AAED,wBAAgB,wBAAwB,IAAI,0BAA0B,CAQrE"}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useMemo } from "react";
4
+ import { defaultFetcher } from "./client.js";
5
+ const VoyantBookingsContext = createContext(null);
6
+ export function VoyantBookingsProvider({ baseUrl, fetcher, children, }) {
7
+ const value = useMemo(() => ({ baseUrl, fetcher: fetcher ?? defaultFetcher }), [baseUrl, fetcher]);
8
+ return _jsx(VoyantBookingsContext.Provider, { value: value, children: children });
9
+ }
10
+ export function useVoyantBookingsContext() {
11
+ const context = useContext(VoyantBookingsContext);
12
+ if (!context) {
13
+ throw new Error('useVoyantBookingsContext must be used inside <VoyantBookingsProvider>. Wrap your app with <VoyantBookingsProvider baseUrl="/api" />.');
14
+ }
15
+ return context;
16
+ }
@@ -0,0 +1,17 @@
1
+ export interface BookingsListFilters {
2
+ status?: string | undefined;
3
+ search?: string | undefined;
4
+ limit?: number | undefined;
5
+ offset?: number | undefined;
6
+ }
7
+ export declare const bookingsQueryKeys: {
8
+ readonly all: readonly ["voyant", "bookings"];
9
+ readonly bookings: () => readonly ["voyant", "bookings", "bookings"];
10
+ readonly bookingsList: (filters: BookingsListFilters) => readonly ["voyant", "bookings", "bookings", "list", BookingsListFilters];
11
+ readonly booking: (id: string) => readonly ["voyant", "bookings", "bookings", "detail", string];
12
+ readonly passengers: (bookingId: string) => readonly ["voyant", "bookings", "bookings", "detail", string, "passengers"];
13
+ readonly supplierStatuses: (bookingId: string) => readonly ["voyant", "bookings", "bookings", "detail", string, "supplier-statuses"];
14
+ readonly activity: (bookingId: string) => readonly ["voyant", "bookings", "bookings", "detail", string, "activity"];
15
+ readonly notes: (bookingId: string) => readonly ["voyant", "bookings", "bookings", "detail", string, "notes"];
16
+ };
17
+ //# 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,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,eAAO,MAAM,iBAAiB;;;qCAIJ,mBAAmB;2BAE7B,MAAM;qCAEI,MAAM;2CAEA,MAAM;mCAEd,MAAM;gCACT,MAAM;CACjB,CAAA"}
@@ -0,0 +1,10 @@
1
+ export const bookingsQueryKeys = {
2
+ all: ["voyant", "bookings"],
3
+ bookings: () => [...bookingsQueryKeys.all, "bookings"],
4
+ bookingsList: (filters) => [...bookingsQueryKeys.bookings(), "list", filters],
5
+ booking: (id) => [...bookingsQueryKeys.bookings(), "detail", id],
6
+ passengers: (bookingId) => [...bookingsQueryKeys.booking(bookingId), "passengers"],
7
+ supplierStatuses: (bookingId) => [...bookingsQueryKeys.booking(bookingId), "supplier-statuses"],
8
+ activity: (bookingId) => [...bookingsQueryKeys.booking(bookingId), "activity"],
9
+ notes: (bookingId) => [...bookingsQueryKeys.booking(bookingId), "notes"],
10
+ };
@@ -0,0 +1,221 @@
1
+ import { z } from "zod";
2
+ export declare const paginatedEnvelope: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
3
+ data: z.ZodArray<T>;
4
+ total: z.ZodNumber;
5
+ limit: z.ZodNumber;
6
+ offset: z.ZodNumber;
7
+ }, z.core.$strip>;
8
+ export declare const singleEnvelope: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
9
+ data: T;
10
+ }, z.core.$strip>;
11
+ export declare const arrayEnvelope: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
12
+ data: z.ZodArray<T>;
13
+ }, z.core.$strip>;
14
+ export declare const successEnvelope: z.ZodObject<{
15
+ success: z.ZodBoolean;
16
+ }, z.core.$strip>;
17
+ export declare const bookingStatusSchema: z.ZodEnum<{
18
+ draft: "draft";
19
+ on_hold: "on_hold";
20
+ confirmed: "confirmed";
21
+ in_progress: "in_progress";
22
+ completed: "completed";
23
+ expired: "expired";
24
+ cancelled: "cancelled";
25
+ }>;
26
+ export declare const supplierConfirmationStatusSchema: z.ZodEnum<{
27
+ confirmed: "confirmed";
28
+ cancelled: "cancelled";
29
+ pending: "pending";
30
+ rejected: "rejected";
31
+ }>;
32
+ export declare const bookingRecordSchema: z.ZodObject<{
33
+ id: z.ZodString;
34
+ bookingNumber: z.ZodString;
35
+ status: z.ZodEnum<{
36
+ draft: "draft";
37
+ on_hold: "on_hold";
38
+ confirmed: "confirmed";
39
+ in_progress: "in_progress";
40
+ completed: "completed";
41
+ expired: "expired";
42
+ cancelled: "cancelled";
43
+ }>;
44
+ personId: z.ZodNullable<z.ZodString>;
45
+ organizationId: z.ZodNullable<z.ZodString>;
46
+ sellCurrency: z.ZodString;
47
+ sellAmountCents: z.ZodNullable<z.ZodNumber>;
48
+ costAmountCents: z.ZodNullable<z.ZodNumber>;
49
+ marginPercent: z.ZodNullable<z.ZodNumber>;
50
+ startDate: z.ZodNullable<z.ZodString>;
51
+ endDate: z.ZodNullable<z.ZodString>;
52
+ pax: z.ZodNullable<z.ZodNumber>;
53
+ internalNotes: z.ZodNullable<z.ZodString>;
54
+ createdAt: z.ZodString;
55
+ updatedAt: z.ZodString;
56
+ }, z.core.$strip>;
57
+ export type BookingRecord = z.infer<typeof bookingRecordSchema>;
58
+ export declare const bookingPassengerRecordSchema: z.ZodObject<{
59
+ id: z.ZodString;
60
+ bookingId: z.ZodString;
61
+ firstName: z.ZodString;
62
+ lastName: z.ZodString;
63
+ email: z.ZodNullable<z.ZodString>;
64
+ phone: z.ZodNullable<z.ZodString>;
65
+ specialRequests: z.ZodNullable<z.ZodString>;
66
+ isLeadPassenger: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
67
+ createdAt: z.ZodString;
68
+ updatedAt: z.ZodOptional<z.ZodString>;
69
+ }, z.core.$strip>;
70
+ export type BookingPassengerRecord = z.infer<typeof bookingPassengerRecordSchema>;
71
+ export declare const bookingSupplierStatusRecordSchema: z.ZodObject<{
72
+ id: z.ZodString;
73
+ bookingId: z.ZodString;
74
+ supplierServiceId: z.ZodNullable<z.ZodString>;
75
+ serviceName: z.ZodString;
76
+ status: z.ZodEnum<{
77
+ confirmed: "confirmed";
78
+ cancelled: "cancelled";
79
+ pending: "pending";
80
+ rejected: "rejected";
81
+ }>;
82
+ supplierReference: z.ZodNullable<z.ZodString>;
83
+ costCurrency: z.ZodString;
84
+ costAmountCents: z.ZodNumber;
85
+ notes: z.ZodNullable<z.ZodString>;
86
+ confirmedAt: z.ZodNullable<z.ZodString>;
87
+ createdAt: z.ZodString;
88
+ updatedAt: z.ZodString;
89
+ }, z.core.$strip>;
90
+ export type BookingSupplierStatusRecord = z.infer<typeof bookingSupplierStatusRecordSchema>;
91
+ export declare const bookingActivityRecordSchema: z.ZodObject<{
92
+ id: z.ZodString;
93
+ bookingId: z.ZodString;
94
+ actorId: z.ZodNullable<z.ZodString>;
95
+ activityType: z.ZodString;
96
+ description: z.ZodString;
97
+ metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
98
+ createdAt: z.ZodString;
99
+ }, z.core.$strip>;
100
+ export type BookingActivityRecord = z.infer<typeof bookingActivityRecordSchema>;
101
+ export declare const bookingNoteRecordSchema: z.ZodObject<{
102
+ id: z.ZodString;
103
+ bookingId: z.ZodString;
104
+ authorId: z.ZodString;
105
+ content: z.ZodString;
106
+ createdAt: z.ZodString;
107
+ }, z.core.$strip>;
108
+ export type BookingNoteRecord = z.infer<typeof bookingNoteRecordSchema>;
109
+ export declare const bookingListResponse: z.ZodObject<{
110
+ data: z.ZodArray<z.ZodObject<{
111
+ id: z.ZodString;
112
+ bookingNumber: z.ZodString;
113
+ status: z.ZodEnum<{
114
+ draft: "draft";
115
+ on_hold: "on_hold";
116
+ confirmed: "confirmed";
117
+ in_progress: "in_progress";
118
+ completed: "completed";
119
+ expired: "expired";
120
+ cancelled: "cancelled";
121
+ }>;
122
+ personId: z.ZodNullable<z.ZodString>;
123
+ organizationId: z.ZodNullable<z.ZodString>;
124
+ sellCurrency: z.ZodString;
125
+ sellAmountCents: z.ZodNullable<z.ZodNumber>;
126
+ costAmountCents: z.ZodNullable<z.ZodNumber>;
127
+ marginPercent: z.ZodNullable<z.ZodNumber>;
128
+ startDate: z.ZodNullable<z.ZodString>;
129
+ endDate: z.ZodNullable<z.ZodString>;
130
+ pax: z.ZodNullable<z.ZodNumber>;
131
+ internalNotes: z.ZodNullable<z.ZodString>;
132
+ createdAt: z.ZodString;
133
+ updatedAt: z.ZodString;
134
+ }, z.core.$strip>>;
135
+ total: z.ZodNumber;
136
+ limit: z.ZodNumber;
137
+ offset: z.ZodNumber;
138
+ }, z.core.$strip>;
139
+ export declare const bookingSingleResponse: z.ZodObject<{
140
+ data: z.ZodObject<{
141
+ id: z.ZodString;
142
+ bookingNumber: z.ZodString;
143
+ status: z.ZodEnum<{
144
+ draft: "draft";
145
+ on_hold: "on_hold";
146
+ confirmed: "confirmed";
147
+ in_progress: "in_progress";
148
+ completed: "completed";
149
+ expired: "expired";
150
+ cancelled: "cancelled";
151
+ }>;
152
+ personId: z.ZodNullable<z.ZodString>;
153
+ organizationId: z.ZodNullable<z.ZodString>;
154
+ sellCurrency: z.ZodString;
155
+ sellAmountCents: z.ZodNullable<z.ZodNumber>;
156
+ costAmountCents: z.ZodNullable<z.ZodNumber>;
157
+ marginPercent: z.ZodNullable<z.ZodNumber>;
158
+ startDate: z.ZodNullable<z.ZodString>;
159
+ endDate: z.ZodNullable<z.ZodString>;
160
+ pax: z.ZodNullable<z.ZodNumber>;
161
+ internalNotes: z.ZodNullable<z.ZodString>;
162
+ createdAt: z.ZodString;
163
+ updatedAt: z.ZodString;
164
+ }, z.core.$strip>;
165
+ }, z.core.$strip>;
166
+ export declare const bookingPassengersResponse: z.ZodObject<{
167
+ data: z.ZodArray<z.ZodObject<{
168
+ id: z.ZodString;
169
+ bookingId: z.ZodString;
170
+ firstName: z.ZodString;
171
+ lastName: z.ZodString;
172
+ email: z.ZodNullable<z.ZodString>;
173
+ phone: z.ZodNullable<z.ZodString>;
174
+ specialRequests: z.ZodNullable<z.ZodString>;
175
+ isLeadPassenger: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
176
+ createdAt: z.ZodString;
177
+ updatedAt: z.ZodOptional<z.ZodString>;
178
+ }, z.core.$strip>>;
179
+ }, z.core.$strip>;
180
+ export declare const bookingSupplierStatusesResponse: z.ZodObject<{
181
+ data: z.ZodArray<z.ZodObject<{
182
+ id: z.ZodString;
183
+ bookingId: z.ZodString;
184
+ supplierServiceId: z.ZodNullable<z.ZodString>;
185
+ serviceName: z.ZodString;
186
+ status: z.ZodEnum<{
187
+ confirmed: "confirmed";
188
+ cancelled: "cancelled";
189
+ pending: "pending";
190
+ rejected: "rejected";
191
+ }>;
192
+ supplierReference: z.ZodNullable<z.ZodString>;
193
+ costCurrency: z.ZodString;
194
+ costAmountCents: z.ZodNumber;
195
+ notes: z.ZodNullable<z.ZodString>;
196
+ confirmedAt: z.ZodNullable<z.ZodString>;
197
+ createdAt: z.ZodString;
198
+ updatedAt: z.ZodString;
199
+ }, z.core.$strip>>;
200
+ }, z.core.$strip>;
201
+ export declare const bookingActivityResponse: z.ZodObject<{
202
+ data: z.ZodArray<z.ZodObject<{
203
+ id: z.ZodString;
204
+ bookingId: z.ZodString;
205
+ actorId: z.ZodNullable<z.ZodString>;
206
+ activityType: z.ZodString;
207
+ description: z.ZodString;
208
+ metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
209
+ createdAt: z.ZodString;
210
+ }, z.core.$strip>>;
211
+ }, z.core.$strip>;
212
+ export declare const bookingNotesResponse: z.ZodObject<{
213
+ data: z.ZodArray<z.ZodObject<{
214
+ id: z.ZodString;
215
+ bookingId: z.ZodString;
216
+ authorId: z.ZodString;
217
+ content: z.ZodString;
218
+ createdAt: z.ZodString;
219
+ }, z.core.$strip>>;
220
+ }, z.core.$strip>;
221
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;;;;;iBAM7D,CAAA;AAEJ,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;;iBAA6B,CAAA;AAC3F,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;;iBAAsC,CAAA;AACnG,eAAO,MAAM,eAAe;;iBAAqC,CAAA;AAEjE,eAAO,MAAM,mBAAmB;;;;;;;;EAQ9B,CAAA;AAEF,eAAO,MAAM,gCAAgC;;;;;EAK3C,CAAA;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;iBAgB9B,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D,eAAO,MAAM,4BAA4B;;;;;;;;;;;iBAWvC,CAAA;AAEF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAEjF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;iBAa5C,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAE3F,eAAO,MAAM,2BAA2B;;;;;;;;iBAQtC,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAE/E,eAAO,MAAM,uBAAuB;;;;;;iBAMlC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAyC,CAAA;AACzE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAsC,CAAA;AACxE,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;iBAA8C,CAAA;AACpF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;iBAAmD,CAAA;AAC/F,eAAO,MAAM,uBAAuB;;;;;;;;;;iBAA6C,CAAA;AACjF,eAAO,MAAM,oBAAoB;;;;;;;;iBAAyC,CAAA"}
@@ -0,0 +1,90 @@
1
+ import { z } from "zod";
2
+ export const paginatedEnvelope = (item) => z.object({
3
+ data: z.array(item),
4
+ total: z.number().int(),
5
+ limit: z.number().int(),
6
+ offset: z.number().int(),
7
+ });
8
+ export const singleEnvelope = (item) => z.object({ data: item });
9
+ export const arrayEnvelope = (item) => z.object({ data: z.array(item) });
10
+ export const successEnvelope = z.object({ success: z.boolean() });
11
+ export const bookingStatusSchema = z.enum([
12
+ "draft",
13
+ "on_hold",
14
+ "confirmed",
15
+ "in_progress",
16
+ "completed",
17
+ "expired",
18
+ "cancelled",
19
+ ]);
20
+ export const supplierConfirmationStatusSchema = z.enum([
21
+ "pending",
22
+ "confirmed",
23
+ "rejected",
24
+ "cancelled",
25
+ ]);
26
+ export const bookingRecordSchema = z.object({
27
+ id: z.string(),
28
+ bookingNumber: z.string(),
29
+ status: bookingStatusSchema,
30
+ personId: z.string().nullable(),
31
+ organizationId: z.string().nullable(),
32
+ sellCurrency: z.string(),
33
+ sellAmountCents: z.number().int().nullable(),
34
+ costAmountCents: z.number().int().nullable(),
35
+ marginPercent: z.number().int().nullable(),
36
+ startDate: z.string().nullable(),
37
+ endDate: z.string().nullable(),
38
+ pax: z.number().int().nullable(),
39
+ internalNotes: z.string().nullable(),
40
+ createdAt: z.string(),
41
+ updatedAt: z.string(),
42
+ });
43
+ export const bookingPassengerRecordSchema = z.object({
44
+ id: z.string(),
45
+ bookingId: z.string(),
46
+ firstName: z.string(),
47
+ lastName: z.string(),
48
+ email: z.string().nullable(),
49
+ phone: z.string().nullable(),
50
+ specialRequests: z.string().nullable(),
51
+ isLeadPassenger: z.boolean().nullable().optional(),
52
+ createdAt: z.string(),
53
+ updatedAt: z.string().optional(),
54
+ });
55
+ export const bookingSupplierStatusRecordSchema = z.object({
56
+ id: z.string(),
57
+ bookingId: z.string(),
58
+ supplierServiceId: z.string().nullable(),
59
+ serviceName: z.string(),
60
+ status: supplierConfirmationStatusSchema,
61
+ supplierReference: z.string().nullable(),
62
+ costCurrency: z.string(),
63
+ costAmountCents: z.number().int(),
64
+ notes: z.string().nullable(),
65
+ confirmedAt: z.string().nullable(),
66
+ createdAt: z.string(),
67
+ updatedAt: z.string(),
68
+ });
69
+ export const bookingActivityRecordSchema = z.object({
70
+ id: z.string(),
71
+ bookingId: z.string(),
72
+ actorId: z.string().nullable(),
73
+ activityType: z.string(),
74
+ description: z.string(),
75
+ metadata: z.record(z.string(), z.unknown()).nullable(),
76
+ createdAt: z.string(),
77
+ });
78
+ export const bookingNoteRecordSchema = z.object({
79
+ id: z.string(),
80
+ bookingId: z.string(),
81
+ authorId: z.string(),
82
+ content: z.string(),
83
+ createdAt: z.string(),
84
+ });
85
+ export const bookingListResponse = paginatedEnvelope(bookingRecordSchema);
86
+ export const bookingSingleResponse = singleEnvelope(bookingRecordSchema);
87
+ export const bookingPassengersResponse = arrayEnvelope(bookingPassengerRecordSchema);
88
+ export const bookingSupplierStatusesResponse = arrayEnvelope(bookingSupplierStatusRecordSchema);
89
+ export const bookingActivityResponse = arrayEnvelope(bookingActivityRecordSchema);
90
+ export const bookingNotesResponse = arrayEnvelope(bookingNoteRecordSchema);
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@voyantjs/bookings-react",
3
+ "version": "0.2.0",
4
+ "license": "FSL-1.1-Apache-2.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/voyantjs/voyant.git",
8
+ "directory": "packages/bookings-react"
9
+ },
10
+ "type": "module",
11
+ "exports": {
12
+ ".": "./src/index.ts",
13
+ "./provider": "./src/provider.tsx",
14
+ "./hooks": "./src/hooks/index.ts",
15
+ "./client": "./src/client.ts",
16
+ "./query-keys": "./src/query-keys.ts"
17
+ },
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.json",
20
+ "clean": "rm -rf dist",
21
+ "prepack": "pnpm run build",
22
+ "typecheck": "tsc --noEmit",
23
+ "lint": "biome check src/",
24
+ "test": "vitest run --passWithNoTests"
25
+ },
26
+ "peerDependencies": {
27
+ "@voyantjs/bookings": "workspace:*",
28
+ "@tanstack/react-query": "^5.0.0",
29
+ "react": "^19.0.0",
30
+ "react-dom": "^19.0.0",
31
+ "zod": "^4.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@tanstack/react-query": "^5.96.2",
35
+ "@types/react": "^19.2.14",
36
+ "@types/react-dom": "^19.2.3",
37
+ "@voyantjs/bookings": "workspace:*",
38
+ "@voyantjs/voyant-typescript-config": "workspace:*",
39
+ "react": "^19.2.4",
40
+ "react-dom": "^19.2.4",
41
+ "typescript": "^6.0.2",
42
+ "vitest": "^4.1.2",
43
+ "zod": "^4.3.6"
44
+ },
45
+ "files": [
46
+ "dist"
47
+ ],
48
+ "publishConfig": {
49
+ "access": "public",
50
+ "exports": {
51
+ ".": {
52
+ "types": "./dist/index.d.ts",
53
+ "import": "./dist/index.js"
54
+ },
55
+ "./provider": {
56
+ "types": "./dist/provider.d.ts",
57
+ "import": "./dist/provider.js"
58
+ },
59
+ "./hooks": {
60
+ "types": "./dist/hooks/index.d.ts",
61
+ "import": "./dist/hooks/index.js"
62
+ },
63
+ "./client": {
64
+ "types": "./dist/client.d.ts",
65
+ "import": "./dist/client.js"
66
+ },
67
+ "./query-keys": {
68
+ "types": "./dist/query-keys.d.ts",
69
+ "import": "./dist/query-keys.js"
70
+ }
71
+ },
72
+ "main": "./dist/index.js",
73
+ "types": "./dist/index.d.ts"
74
+ }
75
+ }