@voyantjs/distribution-react 0.1.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 (62) hide show
  1. package/README.md +32 -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/constants.d.ts +100 -0
  6. package/dist/constants.d.ts.map +1 -0
  7. package/dist/constants.js +47 -0
  8. package/dist/hooks/index.d.ts +12 -0
  9. package/dist/hooks/index.d.ts.map +1 -0
  10. package/dist/hooks/index.js +12 -0
  11. package/dist/hooks/use-booking-links.d.ts +20 -0
  12. package/dist/hooks/use-booking-links.d.ts.map +1 -0
  13. package/dist/hooks/use-booking-links.js +9 -0
  14. package/dist/hooks/use-bookings.d.ts +14 -0
  15. package/dist/hooks/use-bookings.d.ts.map +1 -0
  16. package/dist/hooks/use-bookings.js +9 -0
  17. package/dist/hooks/use-channel-mutation.d.ts +68 -0
  18. package/dist/hooks/use-channel-mutation.d.ts.map +1 -0
  19. package/dist/hooks/use-channel-mutation.js +49 -0
  20. package/dist/hooks/use-channel.d.ts +16 -0
  21. package/dist/hooks/use-channel.d.ts.map +1 -0
  22. package/dist/hooks/use-channel.js +13 -0
  23. package/dist/hooks/use-channels.d.ts +20 -0
  24. package/dist/hooks/use-channels.d.ts.map +1 -0
  25. package/dist/hooks/use-channels.js +9 -0
  26. package/dist/hooks/use-commission-rules.d.ts +23 -0
  27. package/dist/hooks/use-commission-rules.d.ts.map +1 -0
  28. package/dist/hooks/use-commission-rules.js +9 -0
  29. package/dist/hooks/use-contracts.d.ts +22 -0
  30. package/dist/hooks/use-contracts.d.ts.map +1 -0
  31. package/dist/hooks/use-contracts.js +9 -0
  32. package/dist/hooks/use-mappings.d.ts +19 -0
  33. package/dist/hooks/use-mappings.d.ts.map +1 -0
  34. package/dist/hooks/use-mappings.js +9 -0
  35. package/dist/hooks/use-products.d.ts +14 -0
  36. package/dist/hooks/use-products.d.ts.map +1 -0
  37. package/dist/hooks/use-products.js +9 -0
  38. package/dist/hooks/use-suppliers.d.ts +14 -0
  39. package/dist/hooks/use-suppliers.d.ts.map +1 -0
  40. package/dist/hooks/use-suppliers.js +9 -0
  41. package/dist/hooks/use-webhook-events.d.ts +21 -0
  42. package/dist/hooks/use-webhook-events.d.ts.map +1 -0
  43. package/dist/hooks/use-webhook-events.js +9 -0
  44. package/dist/index.d.ts +9 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +8 -0
  47. package/dist/provider.d.ts +2 -0
  48. package/dist/provider.d.ts.map +1 -0
  49. package/dist/provider.js +1 -0
  50. package/dist/query-keys.d.ts +61 -0
  51. package/dist/query-keys.d.ts.map +1 -0
  52. package/dist/query-keys.js +30 -0
  53. package/dist/query-options.d.ts +999 -0
  54. package/dist/query-options.d.ts.map +1 -0
  55. package/dist/query-options.js +219 -0
  56. package/dist/schemas.d.ts +610 -0
  57. package/dist/schemas.d.ts.map +1 -0
  58. package/dist/schemas.js +143 -0
  59. package/dist/utils.d.ts +10 -0
  60. package/dist/utils.d.ts.map +1 -0
  61. package/dist/utils.js +44 -0
  62. package/package.json +79 -0
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @voyantjs/availability-react
2
+
3
+ React runtime package for Voyant availability. Provides the shared availability provider, typed fetch client, query keys, constants, and TanStack Query hooks that power availability-focused frontend experiences.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @voyantjs/availability-react @voyantjs/availability @tanstack/react-query react react-dom zod
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { VoyantAvailabilityProvider, useSlots } from "@voyantjs/availability-react"
15
+
16
+ function App() {
17
+ return (
18
+ <VoyantAvailabilityProvider baseUrl="/api">
19
+ <SlotsList />
20
+ </VoyantAvailabilityProvider>
21
+ )
22
+ }
23
+
24
+ function SlotsList() {
25
+ const { data } = useSlots()
26
+ return <>{data?.data.map((slot) => <div key={slot.id}>{slot.dateLocal}</div>)}</>
27
+ }
28
+ ```
29
+
30
+ ## License
31
+
32
+ FSL-1.1-Apache-2.0
@@ -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;AAcD,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,CAiCf"}
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,100 @@
1
+ export declare const NONE_VALUE = "__none__";
2
+ export declare const channelKindOptions: readonly [{
3
+ readonly value: "direct";
4
+ readonly label: "Direct";
5
+ }, {
6
+ readonly value: "affiliate";
7
+ readonly label: "Affiliate";
8
+ }, {
9
+ readonly value: "ota";
10
+ readonly label: "OTA";
11
+ }, {
12
+ readonly value: "reseller";
13
+ readonly label: "Reseller";
14
+ }, {
15
+ readonly value: "marketplace";
16
+ readonly label: "Marketplace";
17
+ }, {
18
+ readonly value: "api_partner";
19
+ readonly label: "API Partner";
20
+ }];
21
+ export declare const channelStatusOptions: readonly [{
22
+ readonly value: "active";
23
+ readonly label: "Active";
24
+ }, {
25
+ readonly value: "inactive";
26
+ readonly label: "Inactive";
27
+ }, {
28
+ readonly value: "pending";
29
+ readonly label: "Pending";
30
+ }, {
31
+ readonly value: "archived";
32
+ readonly label: "Archived";
33
+ }];
34
+ export declare const contractStatusOptions: readonly [{
35
+ readonly value: "draft";
36
+ readonly label: "Draft";
37
+ }, {
38
+ readonly value: "active";
39
+ readonly label: "Active";
40
+ }, {
41
+ readonly value: "expired";
42
+ readonly label: "Expired";
43
+ }, {
44
+ readonly value: "terminated";
45
+ readonly label: "Terminated";
46
+ }];
47
+ export declare const paymentOwnerOptions: readonly [{
48
+ readonly value: "operator";
49
+ readonly label: "Operator";
50
+ }, {
51
+ readonly value: "channel";
52
+ readonly label: "Channel";
53
+ }, {
54
+ readonly value: "split";
55
+ readonly label: "Split";
56
+ }];
57
+ export declare const cancellationOwnerOptions: readonly [{
58
+ readonly value: "operator";
59
+ readonly label: "Operator";
60
+ }, {
61
+ readonly value: "channel";
62
+ readonly label: "Channel";
63
+ }, {
64
+ readonly value: "mixed";
65
+ readonly label: "Mixed";
66
+ }];
67
+ export declare const commissionScopeOptions: readonly [{
68
+ readonly value: "booking";
69
+ readonly label: "Booking";
70
+ }, {
71
+ readonly value: "product";
72
+ readonly label: "Product";
73
+ }, {
74
+ readonly value: "rate";
75
+ readonly label: "Rate";
76
+ }, {
77
+ readonly value: "category";
78
+ readonly label: "Category";
79
+ }];
80
+ export declare const commissionTypeOptions: readonly [{
81
+ readonly value: "fixed";
82
+ readonly label: "Fixed";
83
+ }, {
84
+ readonly value: "percentage";
85
+ readonly label: "Percentage";
86
+ }];
87
+ export declare const webhookStatusOptions: readonly [{
88
+ readonly value: "pending";
89
+ readonly label: "Pending";
90
+ }, {
91
+ readonly value: "processed";
92
+ readonly label: "Processed";
93
+ }, {
94
+ readonly value: "failed";
95
+ readonly label: "Failed";
96
+ }, {
97
+ readonly value: "ignored";
98
+ readonly label: "Ignored";
99
+ }];
100
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,aAAa,CAAA;AAEpC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;EAOrB,CAAA;AAEV,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAKvB,CAAA;AAEV,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAKxB,CAAA;AAEV,eAAO,MAAM,mBAAmB;;;;;;;;;EAItB,CAAA;AAEV,eAAO,MAAM,wBAAwB;;;;;;;;;EAI3B,CAAA;AAEV,eAAO,MAAM,sBAAsB;;;;;;;;;;;;EAKzB,CAAA;AAEV,eAAO,MAAM,qBAAqB;;;;;;EAGxB,CAAA;AAEV,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EAKvB,CAAA"}
@@ -0,0 +1,47 @@
1
+ export const NONE_VALUE = "__none__";
2
+ export const channelKindOptions = [
3
+ { value: "direct", label: "Direct" },
4
+ { value: "affiliate", label: "Affiliate" },
5
+ { value: "ota", label: "OTA" },
6
+ { value: "reseller", label: "Reseller" },
7
+ { value: "marketplace", label: "Marketplace" },
8
+ { value: "api_partner", label: "API Partner" },
9
+ ];
10
+ export const channelStatusOptions = [
11
+ { value: "active", label: "Active" },
12
+ { value: "inactive", label: "Inactive" },
13
+ { value: "pending", label: "Pending" },
14
+ { value: "archived", label: "Archived" },
15
+ ];
16
+ export const contractStatusOptions = [
17
+ { value: "draft", label: "Draft" },
18
+ { value: "active", label: "Active" },
19
+ { value: "expired", label: "Expired" },
20
+ { value: "terminated", label: "Terminated" },
21
+ ];
22
+ export const paymentOwnerOptions = [
23
+ { value: "operator", label: "Operator" },
24
+ { value: "channel", label: "Channel" },
25
+ { value: "split", label: "Split" },
26
+ ];
27
+ export const cancellationOwnerOptions = [
28
+ { value: "operator", label: "Operator" },
29
+ { value: "channel", label: "Channel" },
30
+ { value: "mixed", label: "Mixed" },
31
+ ];
32
+ export const commissionScopeOptions = [
33
+ { value: "booking", label: "Booking" },
34
+ { value: "product", label: "Product" },
35
+ { value: "rate", label: "Rate" },
36
+ { value: "category", label: "Category" },
37
+ ];
38
+ export const commissionTypeOptions = [
39
+ { value: "fixed", label: "Fixed" },
40
+ { value: "percentage", label: "Percentage" },
41
+ ];
42
+ export const webhookStatusOptions = [
43
+ { value: "pending", label: "Pending" },
44
+ { value: "processed", label: "Processed" },
45
+ { value: "failed", label: "Failed" },
46
+ { value: "ignored", label: "Ignored" },
47
+ ];
@@ -0,0 +1,12 @@
1
+ export * from "./use-booking-links.js";
2
+ export * from "./use-bookings.js";
3
+ export * from "./use-channel.js";
4
+ export * from "./use-channel-mutation.js";
5
+ export * from "./use-channels.js";
6
+ export * from "./use-commission-rules.js";
7
+ export * from "./use-contracts.js";
8
+ export * from "./use-mappings.js";
9
+ export * from "./use-products.js";
10
+ export * from "./use-suppliers.js";
11
+ export * from "./use-webhook-events.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAEA,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,2BAA2B,CAAA;AACzC,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ export * from "./use-booking-links.js";
3
+ export * from "./use-bookings.js";
4
+ export * from "./use-channel.js";
5
+ export * from "./use-channel-mutation.js";
6
+ export * from "./use-channels.js";
7
+ export * from "./use-commission-rules.js";
8
+ export * from "./use-contracts.js";
9
+ export * from "./use-mappings.js";
10
+ export * from "./use-products.js";
11
+ export * from "./use-suppliers.js";
12
+ export * from "./use-webhook-events.js";
@@ -0,0 +1,20 @@
1
+ import type { BookingLinksListFilters } from "../query-keys.js";
2
+ export interface UseBookingLinksOptions extends BookingLinksListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useBookingLinks(options?: UseBookingLinksOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ channelId: string;
9
+ bookingId: string;
10
+ externalBookingId: string | null;
11
+ externalReference: string | null;
12
+ externalStatus: string | null;
13
+ bookedAtExternal: string | null;
14
+ lastSyncedAt: string | null;
15
+ }[];
16
+ total: number;
17
+ limit: number;
18
+ offset: number;
19
+ }, Error>;
20
+ //# sourceMappingURL=use-booking-links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-booking-links.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-links.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG/D,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,sBAA2B;;;;;;;;;;;;;;UAInE"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantDistributionContext } from "../provider.js";
4
+ import { getBookingLinksQueryOptions } from "../query-options.js";
5
+ export function useBookingLinks(options = {}) {
6
+ const client = useVoyantDistributionContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({ ...getBookingLinksQueryOptions(client, options), enabled });
9
+ }
@@ -0,0 +1,14 @@
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
+ }[];
10
+ total: number;
11
+ limit: number;
12
+ offset: number;
13
+ }, Error>;
14
+ //# 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":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAG3D,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;UAI3D"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantDistributionContext } from "../provider.js";
4
+ import { getBookingsQueryOptions } from "../query-options.js";
5
+ export function useBookings(options = {}) {
6
+ const client = useVoyantDistributionContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({ ...getBookingsQueryOptions(client, options), enabled });
9
+ }
@@ -0,0 +1,68 @@
1
+ import { z } from "zod";
2
+ declare const channelInputSchema: z.ZodObject<{
3
+ name: z.ZodString;
4
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
5
+ kind: z.ZodEnum<{
6
+ direct: "direct";
7
+ affiliate: "affiliate";
8
+ ota: "ota";
9
+ reseller: "reseller";
10
+ marketplace: "marketplace";
11
+ api_partner: "api_partner";
12
+ }>;
13
+ status: z.ZodOptional<z.ZodEnum<{
14
+ active: "active";
15
+ inactive: "inactive";
16
+ pending: "pending";
17
+ archived: "archived";
18
+ }>>;
19
+ website: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ contactName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
21
+ contactEmail: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
23
+ }, z.core.$strip>;
24
+ export type CreateChannelInput = z.input<typeof channelInputSchema>;
25
+ export type UpdateChannelInput = Partial<CreateChannelInput>;
26
+ export declare function useChannelMutation(): {
27
+ create: import("@tanstack/react-query").UseMutationResult<{
28
+ id: string;
29
+ name: string;
30
+ kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
31
+ status: "active" | "inactive" | "pending" | "archived";
32
+ website: string | null;
33
+ contactName: string | null;
34
+ contactEmail: string | null;
35
+ metadata: Record<string, unknown> | null;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ }, Error, {
39
+ name: string;
40
+ kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
41
+ description?: string | null | undefined;
42
+ status?: "active" | "inactive" | "pending" | "archived" | undefined;
43
+ website?: string | null | undefined;
44
+ contactName?: string | null | undefined;
45
+ contactEmail?: string | null | undefined;
46
+ metadata?: Record<string, unknown> | null | undefined;
47
+ }, unknown>;
48
+ update: import("@tanstack/react-query").UseMutationResult<{
49
+ id: string;
50
+ name: string;
51
+ kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
52
+ status: "active" | "inactive" | "pending" | "archived";
53
+ website: string | null;
54
+ contactName: string | null;
55
+ contactEmail: string | null;
56
+ metadata: Record<string, unknown> | null;
57
+ createdAt: string;
58
+ updatedAt: string;
59
+ }, Error, {
60
+ id: string;
61
+ input: UpdateChannelInput;
62
+ }, unknown>;
63
+ remove: import("@tanstack/react-query").UseMutationResult<{
64
+ success: boolean;
65
+ }, Error, string, unknown>;
66
+ };
67
+ export {};
68
+ //# sourceMappingURL=use-channel-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-channel-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-channel-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;iBAStB,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AACnE,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;AAE5D,wBAAgB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBU,MAAM;eAAS,kBAAkB;;;;;EA8B5E"}
@@ -0,0 +1,49 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { z } from "zod";
4
+ import { fetchWithValidation } from "../client.js";
5
+ import { useVoyantDistributionContext } from "../provider.js";
6
+ import { distributionQueryKeys } from "../query-keys.js";
7
+ import { channelSingleResponse, successEnvelope } from "../schemas.js";
8
+ const channelInputSchema = z.object({
9
+ name: z.string().min(1).max(255),
10
+ description: z.string().nullable().optional(),
11
+ kind: z.enum(["direct", "affiliate", "ota", "reseller", "marketplace", "api_partner"]),
12
+ status: z.enum(["active", "inactive", "pending", "archived"]).optional(),
13
+ website: z.string().url().nullable().optional(),
14
+ contactName: z.string().nullable().optional(),
15
+ contactEmail: z.string().email().nullable().optional(),
16
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
17
+ });
18
+ export function useChannelMutation() {
19
+ const { baseUrl, fetcher } = useVoyantDistributionContext();
20
+ const queryClient = useQueryClient();
21
+ const create = useMutation({
22
+ mutationFn: async (input) => {
23
+ const { data } = await fetchWithValidation("/v1/distribution/channels", channelSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
24
+ return data;
25
+ },
26
+ onSuccess: (data) => {
27
+ void queryClient.invalidateQueries({ queryKey: distributionQueryKeys.channels() });
28
+ queryClient.setQueryData(distributionQueryKeys.channel(data.id), data);
29
+ },
30
+ });
31
+ const update = useMutation({
32
+ mutationFn: async ({ id, input }) => {
33
+ const { data } = await fetchWithValidation(`/v1/distribution/channels/${id}`, channelSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
34
+ return data;
35
+ },
36
+ onSuccess: (data) => {
37
+ void queryClient.invalidateQueries({ queryKey: distributionQueryKeys.channels() });
38
+ queryClient.setQueryData(distributionQueryKeys.channel(data.id), data);
39
+ },
40
+ });
41
+ const remove = useMutation({
42
+ mutationFn: async (id) => fetchWithValidation(`/v1/distribution/channels/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
43
+ onSuccess: (_data, id) => {
44
+ void queryClient.invalidateQueries({ queryKey: distributionQueryKeys.channels() });
45
+ queryClient.removeQueries({ queryKey: distributionQueryKeys.channel(id) });
46
+ },
47
+ });
48
+ return { create, update, remove };
49
+ }
@@ -0,0 +1,16 @@
1
+ export interface UseChannelOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useChannel(id: string | null | undefined, options?: UseChannelOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ name: string;
7
+ kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
8
+ status: "active" | "inactive" | "pending" | "archived";
9
+ website: string | null;
10
+ contactName: string | null;
11
+ contactEmail: string | null;
12
+ metadata: Record<string, unknown> | null;
13
+ createdAt: string;
14
+ updatedAt: string;
15
+ }, Error>;
16
+ //# sourceMappingURL=use-channel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-channel.d.ts","sourceRoot":"","sources":["../../src/hooks/use-channel.ts"],"names":[],"mappings":"AAOA,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;;;;;;;;;;;UASxF"}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantDistributionContext } from "../provider.js";
4
+ import { getChannelQueryOptions } from "../query-options.js";
5
+ export function useChannel(id, options = {}) {
6
+ const client = useVoyantDistributionContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getChannelQueryOptions(client, id ?? "__missing__"),
10
+ select: (result) => result.data,
11
+ enabled: enabled && Boolean(id),
12
+ });
13
+ }
@@ -0,0 +1,20 @@
1
+ import type { ChannelsListFilters } from "../query-keys.js";
2
+ export interface UseChannelsOptions extends ChannelsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useChannels(options?: UseChannelsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ name: string;
9
+ kind: "direct" | "affiliate" | "ota" | "reseller" | "marketplace" | "api_partner";
10
+ status: "active" | "inactive" | "pending" | "archived";
11
+ website: string | null;
12
+ contactName: string | null;
13
+ contactEmail: string | null;
14
+ metadata: Record<string, unknown> | null;
15
+ }[];
16
+ total: number;
17
+ limit: number;
18
+ offset: number;
19
+ }, Error>;
20
+ //# sourceMappingURL=use-channels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-channels.d.ts","sourceRoot":"","sources":["../../src/hooks/use-channels.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAG3D,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;;;;;;;UAI3D"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantDistributionContext } from "../provider.js";
4
+ import { getChannelsQueryOptions } from "../query-options.js";
5
+ export function useChannels(options = {}) {
6
+ const client = useVoyantDistributionContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({ ...getChannelsQueryOptions(client, options), enabled });
9
+ }
@@ -0,0 +1,23 @@
1
+ import type { CommissionRulesListFilters } from "../query-keys.js";
2
+ export interface UseCommissionRulesOptions extends CommissionRulesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useCommissionRules(options?: UseCommissionRulesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ contractId: string;
9
+ scope: "booking" | "product" | "rate" | "category";
10
+ productId: string | null;
11
+ externalRateId: string | null;
12
+ externalCategoryId: string | null;
13
+ commissionType: "fixed" | "percentage";
14
+ amountCents: number | null;
15
+ percentBasisPoints: number | null;
16
+ validFrom: string | null;
17
+ validTo: string | null;
18
+ }[];
19
+ total: number;
20
+ limit: number;
21
+ offset: number;
22
+ }, Error>;
23
+ //# sourceMappingURL=use-commission-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-commission-rules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-commission-rules.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAGlE,MAAM,WAAW,yBAA0B,SAAQ,0BAA0B;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B;;;;;;;;;;;;;;;;;UAIzE"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantDistributionContext } from "../provider.js";
4
+ import { getCommissionRulesQueryOptions } from "../query-options.js";
5
+ export function useCommissionRules(options = {}) {
6
+ const client = useVoyantDistributionContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({ ...getCommissionRulesQueryOptions(client, options), enabled });
9
+ }
@@ -0,0 +1,22 @@
1
+ import type { ContractsListFilters } from "../query-keys.js";
2
+ export interface UseContractsOptions extends ContractsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useContracts(options?: UseContractsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ channelId: string;
9
+ supplierId: string | null;
10
+ status: "active" | "draft" | "expired" | "terminated";
11
+ startsAt: string;
12
+ endsAt: string | null;
13
+ paymentOwner: "operator" | "channel" | "split";
14
+ cancellationOwner: "operator" | "channel" | "mixed";
15
+ settlementTerms: string | null;
16
+ notes: string | null;
17
+ }[];
18
+ total: number;
19
+ limit: number;
20
+ offset: number;
21
+ }, Error>;
22
+ //# sourceMappingURL=use-contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-contracts.d.ts","sourceRoot":"","sources":["../../src/hooks/use-contracts.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAG5D,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;;;;UAI7D"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantDistributionContext } from "../provider.js";
4
+ import { getContractsQueryOptions } from "../query-options.js";
5
+ export function useContracts(options = {}) {
6
+ const client = useVoyantDistributionContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({ ...getContractsQueryOptions(client, options), enabled });
9
+ }
@@ -0,0 +1,19 @@
1
+ import type { MappingsListFilters } from "../query-keys.js";
2
+ export interface UseMappingsOptions extends MappingsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useMappings(options?: UseMappingsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ channelId: string;
9
+ productId: string;
10
+ externalProductId: string;
11
+ externalRateId: string | null;
12
+ externalCategoryId: string | null;
13
+ active: boolean;
14
+ }[];
15
+ total: number;
16
+ limit: number;
17
+ offset: number;
18
+ }, Error>;
19
+ //# sourceMappingURL=use-mappings.d.ts.map