@voyantjs/availability-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.
- package/README.md +32 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +59 -0
- package/dist/constants.d.ts +24 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +17 -0
- package/dist/hooks/index.d.ts +13 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/use-closeouts.d.ts +18 -0
- package/dist/hooks/use-closeouts.d.ts.map +1 -0
- package/dist/hooks/use-closeouts.js +9 -0
- package/dist/hooks/use-pickup-points.d.ts +18 -0
- package/dist/hooks/use-pickup-points.d.ts.map +1 -0
- package/dist/hooks/use-pickup-points.js +9 -0
- package/dist/hooks/use-products.d.ts +14 -0
- package/dist/hooks/use-products.d.ts.map +1 -0
- package/dist/hooks/use-products.js +9 -0
- package/dist/hooks/use-rules.d.ts +20 -0
- package/dist/hooks/use-rules.d.ts.map +1 -0
- package/dist/hooks/use-rules.js +9 -0
- package/dist/hooks/use-slots.d.ts +25 -0
- package/dist/hooks/use-slots.d.ts.map +1 -0
- package/dist/hooks/use-slots.js +9 -0
- package/dist/hooks/use-start-times.d.ts +19 -0
- package/dist/hooks/use-start-times.d.ts.map +1 -0
- package/dist/hooks/use-start-times.js +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -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 +52 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +22 -0
- package/dist/query-options.d.ts +748 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +190 -0
- package/dist/schemas.d.ts +311 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +111 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +27 -0
- 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
|
package/dist/client.d.ts
ADDED
|
@@ -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,24 @@
|
|
|
1
|
+
import type { AvailabilitySlotRow } from "./schemas.js";
|
|
2
|
+
export declare const NONE_VALUE = "__none__";
|
|
3
|
+
export declare const booleanOptions: readonly [{
|
|
4
|
+
readonly value: "true";
|
|
5
|
+
readonly label: "Yes";
|
|
6
|
+
}, {
|
|
7
|
+
readonly value: "false";
|
|
8
|
+
readonly label: "No";
|
|
9
|
+
}];
|
|
10
|
+
export declare const slotStatusOptions: readonly [{
|
|
11
|
+
readonly value: "open";
|
|
12
|
+
readonly label: "Open";
|
|
13
|
+
}, {
|
|
14
|
+
readonly value: "closed";
|
|
15
|
+
readonly label: "Closed";
|
|
16
|
+
}, {
|
|
17
|
+
readonly value: "sold_out";
|
|
18
|
+
readonly label: "Sold Out";
|
|
19
|
+
}, {
|
|
20
|
+
readonly value: "cancelled";
|
|
21
|
+
readonly label: "Cancelled";
|
|
22
|
+
}];
|
|
23
|
+
export declare const slotStatusVariant: Record<AvailabilitySlotRow["status"], "default" | "secondary" | "outline" | "destructive">;
|
|
24
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAEvD,eAAO,MAAM,UAAU,aAAa,CAAA;AAEpC,eAAO,MAAM,cAAc;;;;;;EAGjB,CAAA;AAEV,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAKpB,CAAA;AAEV,eAAO,MAAM,iBAAiB,EAAE,MAAM,CACpC,mBAAmB,CAAC,QAAQ,CAAC,EAC7B,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,aAAa,CAMpD,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const NONE_VALUE = "__none__";
|
|
2
|
+
export const booleanOptions = [
|
|
3
|
+
{ value: "true", label: "Yes" },
|
|
4
|
+
{ value: "false", label: "No" },
|
|
5
|
+
];
|
|
6
|
+
export const slotStatusOptions = [
|
|
7
|
+
{ value: "open", label: "Open" },
|
|
8
|
+
{ value: "closed", label: "Closed" },
|
|
9
|
+
{ value: "sold_out", label: "Sold Out" },
|
|
10
|
+
{ value: "cancelled", label: "Cancelled" },
|
|
11
|
+
];
|
|
12
|
+
export const slotStatusVariant = {
|
|
13
|
+
open: "default",
|
|
14
|
+
closed: "secondary",
|
|
15
|
+
sold_out: "destructive",
|
|
16
|
+
cancelled: "outline",
|
|
17
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { UseCloseoutsOptions } from "./use-closeouts.js";
|
|
2
|
+
export { useCloseouts } from "./use-closeouts.js";
|
|
3
|
+
export type { UsePickupPointsOptions } from "./use-pickup-points.js";
|
|
4
|
+
export { usePickupPoints } from "./use-pickup-points.js";
|
|
5
|
+
export type { UseProductsOptions } from "./use-products.js";
|
|
6
|
+
export { useProducts } from "./use-products.js";
|
|
7
|
+
export type { UseRulesOptions } from "./use-rules.js";
|
|
8
|
+
export { useRules } from "./use-rules.js";
|
|
9
|
+
export type { UseSlotsOptions } from "./use-slots.js";
|
|
10
|
+
export { useSlots } from "./use-slots.js";
|
|
11
|
+
export type { UseStartTimesOptions } from "./use-start-times.js";
|
|
12
|
+
export { useStartTimes } from "./use-start-times.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { useCloseouts } from "./use-closeouts.js";
|
|
2
|
+
export { usePickupPoints } from "./use-pickup-points.js";
|
|
3
|
+
export { useProducts } from "./use-products.js";
|
|
4
|
+
export { useRules } from "./use-rules.js";
|
|
5
|
+
export { useSlots } from "./use-slots.js";
|
|
6
|
+
export { useStartTimes } from "./use-start-times.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AvailabilityCloseoutsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseCloseoutsOptions extends AvailabilityCloseoutsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useCloseouts(options?: UseCloseoutsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
productId: string;
|
|
9
|
+
slotId: string | null;
|
|
10
|
+
dateLocal: string;
|
|
11
|
+
reason: string | null;
|
|
12
|
+
createdBy: string | null;
|
|
13
|
+
}[];
|
|
14
|
+
total: number;
|
|
15
|
+
limit: number;
|
|
16
|
+
offset: number;
|
|
17
|
+
}, Error>;
|
|
18
|
+
//# sourceMappingURL=use-closeouts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-closeouts.d.ts","sourceRoot":"","sources":["../../src/hooks/use-closeouts.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,kBAAkB,CAAA;AAGxE,MAAM,WAAW,mBAAoB,SAAQ,gCAAgC;IAC3E,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 { useVoyantAvailabilityContext } from "../provider.js";
|
|
4
|
+
import { getCloseoutsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useCloseouts(options = {}) {
|
|
6
|
+
const client = useVoyantAvailabilityContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getCloseoutsQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AvailabilityPickupPointsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UsePickupPointsOptions extends AvailabilityPickupPointsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function usePickupPoints(options?: UsePickupPointsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
productId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
locationText: string | null;
|
|
12
|
+
active: boolean;
|
|
13
|
+
}[];
|
|
14
|
+
total: number;
|
|
15
|
+
limit: number;
|
|
16
|
+
offset: number;
|
|
17
|
+
}, Error>;
|
|
18
|
+
//# sourceMappingURL=use-pickup-points.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-pickup-points.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pickup-points.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAA;AAG3E,MAAM,WAAW,sBAAuB,SAAQ,mCAAmC;IACjF,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 { useVoyantAvailabilityContext } from "../provider.js";
|
|
4
|
+
import { getPickupPointsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function usePickupPoints(options = {}) {
|
|
6
|
+
const client = useVoyantAvailabilityContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getPickupPointsQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ProductListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseProductsOptions extends ProductListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useProducts(options?: UseProductsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
}[];
|
|
10
|
+
total: number;
|
|
11
|
+
limit: number;
|
|
12
|
+
offset: number;
|
|
13
|
+
}, Error>;
|
|
14
|
+
//# sourceMappingURL=use-products.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../src/hooks/use-products.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAG1D,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,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 { useVoyantAvailabilityContext } from "../provider.js";
|
|
4
|
+
import { getProductsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useProducts(options = {}) {
|
|
6
|
+
const client = useVoyantAvailabilityContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getProductsQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AvailabilityRulesListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseRulesOptions extends AvailabilityRulesListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useRules(options?: UseRulesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
productId: string;
|
|
9
|
+
timezone: string;
|
|
10
|
+
recurrenceRule: string;
|
|
11
|
+
maxCapacity: number;
|
|
12
|
+
maxPickupCapacity: number | null;
|
|
13
|
+
cutoffMinutes: number | null;
|
|
14
|
+
active: boolean;
|
|
15
|
+
}[];
|
|
16
|
+
total: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
offset: number;
|
|
19
|
+
}, Error>;
|
|
20
|
+
//# sourceMappingURL=use-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-rules.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAGpE,MAAM,WAAW,eAAgB,SAAQ,4BAA4B;IACnE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,QAAQ,CAAC,OAAO,GAAE,eAAoB;;;;;;;;;;;;;;UAIrD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantAvailabilityContext } from "../provider.js";
|
|
4
|
+
import { getRulesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRules(options = {}) {
|
|
6
|
+
const client = useVoyantAvailabilityContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getRulesQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AvailabilitySlotsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseSlotsOptions extends AvailabilitySlotsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useSlots(options?: UseSlotsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
productId: string;
|
|
9
|
+
availabilityRuleId: string | null;
|
|
10
|
+
startTimeId: string | null;
|
|
11
|
+
dateLocal: string;
|
|
12
|
+
startsAt: string;
|
|
13
|
+
endsAt: string | null;
|
|
14
|
+
timezone: string;
|
|
15
|
+
status: "open" | "closed" | "sold_out" | "cancelled";
|
|
16
|
+
unlimited: boolean;
|
|
17
|
+
initialPax: number | null;
|
|
18
|
+
remainingPax: number | null;
|
|
19
|
+
notes: string | null;
|
|
20
|
+
}[];
|
|
21
|
+
total: number;
|
|
22
|
+
limit: number;
|
|
23
|
+
offset: number;
|
|
24
|
+
}, Error>;
|
|
25
|
+
//# sourceMappingURL=use-slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-slots.d.ts","sourceRoot":"","sources":["../../src/hooks/use-slots.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAGpE,MAAM,WAAW,eAAgB,SAAQ,4BAA4B;IACnE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,QAAQ,CAAC,OAAO,GAAE,eAAoB;;;;;;;;;;;;;;;;;;;UAIrD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantAvailabilityContext } from "../provider.js";
|
|
4
|
+
import { getSlotsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useSlots(options = {}) {
|
|
6
|
+
const client = useVoyantAvailabilityContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getSlotsQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AvailabilityStartTimesListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseStartTimesOptions extends AvailabilityStartTimesListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useStartTimes(options?: UseStartTimesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
productId: string;
|
|
9
|
+
label: string | null;
|
|
10
|
+
startTimeLocal: string;
|
|
11
|
+
durationMinutes: number | null;
|
|
12
|
+
sortOrder: number;
|
|
13
|
+
active: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
total: number;
|
|
16
|
+
limit: number;
|
|
17
|
+
offset: number;
|
|
18
|
+
}, Error>;
|
|
19
|
+
//# sourceMappingURL=use-start-times.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-start-times.d.ts","sourceRoot":"","sources":["../../src/hooks/use-start-times.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAA;AAGzE,MAAM,WAAW,oBAAqB,SAAQ,iCAAiC;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB;;;;;;;;;;;;;UAI/D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantAvailabilityContext } from "../provider.js";
|
|
4
|
+
import { getStartTimesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useStartTimes(options = {}) {
|
|
6
|
+
const client = useVoyantAvailabilityContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getStartTimesQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, } from "./client.js";
|
|
2
|
+
export * from "./constants.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export { useVoyantAvailabilityContext, type VoyantAvailabilityContextValue, VoyantAvailabilityProvider, type VoyantAvailabilityProviderProps, } from "./provider.js";
|
|
5
|
+
export { availabilityQueryKeys } from "./query-keys.js";
|
|
6
|
+
export { getCloseoutsQueryOptions, getPickupPointsQueryOptions, getProductQueryOptions, getProductsQueryOptions, getRulesQueryOptions, getSlotAssignmentsQueryOptions, getSlotBookingsQueryOptions, getSlotCloseoutsQueryOptions, getSlotPickupsQueryOptions, getSlotQueryOptions, getSlotResourcesQueryOptions, getSlotsQueryOptions, getStartTimesQueryOptions, } from "./query-options.js";
|
|
7
|
+
export * from "./schemas.js";
|
|
8
|
+
export * from "./utils.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,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,4BAA4B,EAC5B,KAAK,8BAA8B,EACnC,0BAA0B,EAC1B,KAAK,+BAA+B,GACrC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,EACnB,4BAA4B,EAC5B,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { defaultFetcher, fetchWithValidation, VoyantApiError, } from "./client.js";
|
|
2
|
+
export * from "./constants.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export { useVoyantAvailabilityContext, VoyantAvailabilityProvider, } from "./provider.js";
|
|
5
|
+
export { availabilityQueryKeys } from "./query-keys.js";
|
|
6
|
+
export { getCloseoutsQueryOptions, getPickupPointsQueryOptions, getProductQueryOptions, getProductsQueryOptions, getRulesQueryOptions, getSlotAssignmentsQueryOptions, getSlotBookingsQueryOptions, getSlotCloseoutsQueryOptions, getSlotPickupsQueryOptions, getSlotQueryOptions, getSlotResourcesQueryOptions, getSlotsQueryOptions, getStartTimesQueryOptions, } from "./query-options.js";
|
|
7
|
+
export * from "./schemas.js";
|
|
8
|
+
export * from "./utils.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantAvailabilityContext, type VoyantReactContextValue as VoyantAvailabilityContextValue, VoyantReactProvider as VoyantAvailabilityProvider, type VoyantReactProviderProps as VoyantAvailabilityProviderProps, } 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,4BAA4B,EACrD,KAAK,uBAAuB,IAAI,8BAA8B,EAC9D,mBAAmB,IAAI,0BAA0B,EACjD,KAAK,wBAAwB,IAAI,+BAA+B,GACjE,MAAM,iBAAiB,CAAA"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantAvailabilityContext, VoyantReactProvider as VoyantAvailabilityProvider, } from "@voyantjs/react";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface PaginationFilters {
|
|
2
|
+
limit?: number | undefined;
|
|
3
|
+
offset?: number | undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface ProductListFilters extends PaginationFilters {
|
|
6
|
+
}
|
|
7
|
+
export interface AvailabilityRulesListFilters extends PaginationFilters {
|
|
8
|
+
productId?: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface AvailabilityStartTimesListFilters extends PaginationFilters {
|
|
11
|
+
productId?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface AvailabilitySlotsListFilters extends PaginationFilters {
|
|
14
|
+
productId?: string | undefined;
|
|
15
|
+
availabilityRuleId?: string | undefined;
|
|
16
|
+
startTimeId?: string | undefined;
|
|
17
|
+
status?: string | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface AvailabilityCloseoutsListFilters extends PaginationFilters {
|
|
20
|
+
productId?: string | undefined;
|
|
21
|
+
slotId?: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
export interface AvailabilityPickupPointsListFilters extends PaginationFilters {
|
|
24
|
+
productId?: string | undefined;
|
|
25
|
+
active?: boolean | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface AvailabilitySlotDetailFilters extends PaginationFilters {
|
|
28
|
+
slotId?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
export declare const availabilityQueryKeys: {
|
|
31
|
+
readonly all: readonly ["voyant", "availability"];
|
|
32
|
+
readonly products: () => readonly ["voyant", "availability", "products"];
|
|
33
|
+
readonly productsList: (filters: ProductListFilters) => readonly ["voyant", "availability", "products", "list", ProductListFilters];
|
|
34
|
+
readonly rules: () => readonly ["voyant", "availability", "rules"];
|
|
35
|
+
readonly rulesList: (filters: AvailabilityRulesListFilters) => readonly ["voyant", "availability", "rules", "list", AvailabilityRulesListFilters];
|
|
36
|
+
readonly startTimes: () => readonly ["voyant", "availability", "start-times"];
|
|
37
|
+
readonly startTimesList: (filters: AvailabilityStartTimesListFilters) => readonly ["voyant", "availability", "start-times", "list", AvailabilityStartTimesListFilters];
|
|
38
|
+
readonly slots: () => readonly ["voyant", "availability", "slots"];
|
|
39
|
+
readonly slotsList: (filters: AvailabilitySlotsListFilters) => readonly ["voyant", "availability", "slots", "list", AvailabilitySlotsListFilters];
|
|
40
|
+
readonly closeouts: () => readonly ["voyant", "availability", "closeouts"];
|
|
41
|
+
readonly closeoutsList: (filters: AvailabilityCloseoutsListFilters) => readonly ["voyant", "availability", "closeouts", "list", AvailabilityCloseoutsListFilters];
|
|
42
|
+
readonly pickupPoints: () => readonly ["voyant", "availability", "pickup-points"];
|
|
43
|
+
readonly pickupPointsList: (filters: AvailabilityPickupPointsListFilters) => readonly ["voyant", "availability", "pickup-points", "list", AvailabilityPickupPointsListFilters];
|
|
44
|
+
readonly slotDetail: (id: string) => readonly ["voyant", "availability", "slots", "detail", string];
|
|
45
|
+
readonly slotPickupsList: (filters: AvailabilitySlotDetailFilters) => readonly ["voyant", "availability", "slots", "pickups", "list", AvailabilitySlotDetailFilters];
|
|
46
|
+
readonly slotCloseoutsList: (filters: AvailabilitySlotDetailFilters) => readonly ["voyant", "availability", "slots", "closeouts", "list", AvailabilitySlotDetailFilters];
|
|
47
|
+
readonly slotAssignmentsList: (filters: AvailabilitySlotDetailFilters) => readonly ["voyant", "availability", "slots", "assignments", "list", AvailabilitySlotDetailFilters];
|
|
48
|
+
readonly slotResourcesList: (filters: PaginationFilters) => readonly ["voyant", "availability", "slots", "resources", "list", PaginationFilters];
|
|
49
|
+
readonly slotBookingsList: (filters: PaginationFilters) => readonly ["voyant", "availability", "slots", "bookings", "list", PaginationFilters];
|
|
50
|
+
readonly product: (id: string) => readonly ["voyant", "availability", "products", "detail", string];
|
|
51
|
+
};
|
|
52
|
+
//# 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,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;CAAG;AAEhE,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B;AAED,MAAM,WAAW,iCAAkC,SAAQ,iBAAiB;IAC1E,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B;AAED,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,kBAAkB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACvC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,gCAAiC,SAAQ,iBAAiB;IACzE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,mCAAoC,SAAQ,iBAAiB;IAC5E,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC7B;AAED,MAAM,WAAW,6BAA8B,SAAQ,iBAAiB;IACtE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,eAAO,MAAM,qBAAqB;;;qCAIR,kBAAkB;;kCAIrB,4BAA4B;;uCAIvB,iCAAiC;;kCAItC,4BAA4B;;sCAIxB,gCAAgC;;yCAI7B,mCAAmC;8BAG9C,MAAM;wCACI,6BAA6B;0CAE3B,6BAA6B;4CAE3B,6BAA6B;0CAE/B,iBAAiB;yCAElB,iBAAiB;2BAE/B,MAAM;CACZ,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const availabilityQueryKeys = {
|
|
2
|
+
all: ["voyant", "availability"],
|
|
3
|
+
products: () => [...availabilityQueryKeys.all, "products"],
|
|
4
|
+
productsList: (filters) => [...availabilityQueryKeys.products(), "list", filters],
|
|
5
|
+
rules: () => [...availabilityQueryKeys.all, "rules"],
|
|
6
|
+
rulesList: (filters) => [...availabilityQueryKeys.rules(), "list", filters],
|
|
7
|
+
startTimes: () => [...availabilityQueryKeys.all, "start-times"],
|
|
8
|
+
startTimesList: (filters) => [...availabilityQueryKeys.startTimes(), "list", filters],
|
|
9
|
+
slots: () => [...availabilityQueryKeys.all, "slots"],
|
|
10
|
+
slotsList: (filters) => [...availabilityQueryKeys.slots(), "list", filters],
|
|
11
|
+
closeouts: () => [...availabilityQueryKeys.all, "closeouts"],
|
|
12
|
+
closeoutsList: (filters) => [...availabilityQueryKeys.closeouts(), "list", filters],
|
|
13
|
+
pickupPoints: () => [...availabilityQueryKeys.all, "pickup-points"],
|
|
14
|
+
pickupPointsList: (filters) => [...availabilityQueryKeys.pickupPoints(), "list", filters],
|
|
15
|
+
slotDetail: (id) => [...availabilityQueryKeys.slots(), "detail", id],
|
|
16
|
+
slotPickupsList: (filters) => [...availabilityQueryKeys.slots(), "pickups", "list", filters],
|
|
17
|
+
slotCloseoutsList: (filters) => [...availabilityQueryKeys.slots(), "closeouts", "list", filters],
|
|
18
|
+
slotAssignmentsList: (filters) => [...availabilityQueryKeys.slots(), "assignments", "list", filters],
|
|
19
|
+
slotResourcesList: (filters) => [...availabilityQueryKeys.slots(), "resources", "list", filters],
|
|
20
|
+
slotBookingsList: (filters) => [...availabilityQueryKeys.slots(), "bookings", "list", filters],
|
|
21
|
+
product: (id) => [...availabilityQueryKeys.products(), "detail", id],
|
|
22
|
+
};
|