@voyantjs/resources-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 +36 -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 +44 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +20 -0
- package/dist/hooks/index.d.ts +31 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +15 -0
- package/dist/hooks/use-allocation.d.ts +16 -0
- package/dist/hooks/use-allocation.d.ts.map +1 -0
- package/dist/hooks/use-allocation.js +12 -0
- package/dist/hooks/use-allocations.d.ts +20 -0
- package/dist/hooks/use-allocations.d.ts.map +1 -0
- package/dist/hooks/use-allocations.js +12 -0
- package/dist/hooks/use-assignment.d.ts +17 -0
- package/dist/hooks/use-assignment.d.ts.map +1 -0
- package/dist/hooks/use-assignment.js +12 -0
- package/dist/hooks/use-assignments.d.ts +21 -0
- package/dist/hooks/use-assignments.d.ts.map +1 -0
- package/dist/hooks/use-assignments.js +12 -0
- package/dist/hooks/use-bookings.d.ts +14 -0
- package/dist/hooks/use-bookings.d.ts.map +1 -0
- package/dist/hooks/use-bookings.js +12 -0
- package/dist/hooks/use-closeouts.d.ts +19 -0
- package/dist/hooks/use-closeouts.d.ts.map +1 -0
- package/dist/hooks/use-closeouts.js +12 -0
- package/dist/hooks/use-pool.d.ts +15 -0
- package/dist/hooks/use-pool.d.ts.map +1 -0
- package/dist/hooks/use-pool.js +12 -0
- package/dist/hooks/use-pools.d.ts +19 -0
- package/dist/hooks/use-pools.d.ts.map +1 -0
- package/dist/hooks/use-pools.js +12 -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 +12 -0
- package/dist/hooks/use-resource.d.ts +16 -0
- package/dist/hooks/use-resource.d.ts.map +1 -0
- package/dist/hooks/use-resource.js +12 -0
- package/dist/hooks/use-resources.d.ts +20 -0
- package/dist/hooks/use-resources.d.ts.map +1 -0
- package/dist/hooks/use-resources.js +12 -0
- package/dist/hooks/use-rules.d.ts +15 -0
- package/dist/hooks/use-rules.d.ts.map +1 -0
- package/dist/hooks/use-rules.js +12 -0
- package/dist/hooks/use-slots.d.ts +16 -0
- package/dist/hooks/use-slots.d.ts.map +1 -0
- package/dist/hooks/use-slots.js +12 -0
- package/dist/hooks/use-start-times.d.ts +16 -0
- package/dist/hooks/use-start-times.d.ts.map +1 -0
- package/dist/hooks/use-start-times.js +12 -0
- package/dist/hooks/use-suppliers.d.ts +14 -0
- package/dist/hooks/use-suppliers.d.ts.map +1 -0
- package/dist/hooks/use-suppliers.js +12 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/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 +73 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +29 -0
- package/dist/query-options.d.ts +801 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +237 -0
- package/dist/schemas.d.ts +452 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +126 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +33 -0
- package/package.json +79 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @voyantjs/resources-react
|
|
2
|
+
|
|
3
|
+
React runtime package for Voyant resources. Provides the shared resources provider, typed fetch client, query keys, constants, and TanStack Query hooks that power resource-focused frontend experiences.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @voyantjs/resources-react @voyantjs/resources @tanstack/react-query react react-dom zod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { VoyantResourcesProvider, useResources } from "@voyantjs/resources-react"
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<VoyantResourcesProvider baseUrl="/api">
|
|
19
|
+
<ResourcesList />
|
|
20
|
+
</VoyantResourcesProvider>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function ResourcesList() {
|
|
25
|
+
const { data } = useResources()
|
|
26
|
+
return <>{data?.data.map((resource) => <div key={resource.id}>{resource.name}</div>)}</>
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Relationship To The Registry
|
|
31
|
+
|
|
32
|
+
`@voyantjs/resources-react` is the runtime layer. Installable resource UI blocks should depend on this package for hooks, client state, typed response validation, and shared resource-domain helpers.
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
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,44 @@
|
|
|
1
|
+
export declare const NONE_VALUE = "__none__";
|
|
2
|
+
export declare const resourceKindOptions: readonly [{
|
|
3
|
+
readonly value: "guide";
|
|
4
|
+
readonly label: "Guide";
|
|
5
|
+
}, {
|
|
6
|
+
readonly value: "vehicle";
|
|
7
|
+
readonly label: "Vehicle";
|
|
8
|
+
}, {
|
|
9
|
+
readonly value: "room";
|
|
10
|
+
readonly label: "Room";
|
|
11
|
+
}, {
|
|
12
|
+
readonly value: "boat";
|
|
13
|
+
readonly label: "Boat";
|
|
14
|
+
}, {
|
|
15
|
+
readonly value: "equipment";
|
|
16
|
+
readonly label: "Equipment";
|
|
17
|
+
}, {
|
|
18
|
+
readonly value: "other";
|
|
19
|
+
readonly label: "Other";
|
|
20
|
+
}];
|
|
21
|
+
export declare const allocationModeOptions: readonly [{
|
|
22
|
+
readonly value: "shared";
|
|
23
|
+
readonly label: "Shared";
|
|
24
|
+
}, {
|
|
25
|
+
readonly value: "exclusive";
|
|
26
|
+
readonly label: "Exclusive";
|
|
27
|
+
}];
|
|
28
|
+
export declare const assignmentStatusOptions: readonly [{
|
|
29
|
+
readonly value: "reserved";
|
|
30
|
+
readonly label: "Reserved";
|
|
31
|
+
}, {
|
|
32
|
+
readonly value: "assigned";
|
|
33
|
+
readonly label: "Assigned";
|
|
34
|
+
}, {
|
|
35
|
+
readonly value: "released";
|
|
36
|
+
readonly label: "Released";
|
|
37
|
+
}, {
|
|
38
|
+
readonly value: "cancelled";
|
|
39
|
+
readonly label: "Cancelled";
|
|
40
|
+
}, {
|
|
41
|
+
readonly value: "completed";
|
|
42
|
+
readonly label: "Completed";
|
|
43
|
+
}];
|
|
44
|
+
//# 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,mBAAmB;;;;;;;;;;;;;;;;;;EAOtB,CAAA;AAEV,eAAO,MAAM,qBAAqB;;;;;;EAGxB,CAAA;AAEV,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAM1B,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const NONE_VALUE = "__none__";
|
|
2
|
+
export const resourceKindOptions = [
|
|
3
|
+
{ value: "guide", label: "Guide" },
|
|
4
|
+
{ value: "vehicle", label: "Vehicle" },
|
|
5
|
+
{ value: "room", label: "Room" },
|
|
6
|
+
{ value: "boat", label: "Boat" },
|
|
7
|
+
{ value: "equipment", label: "Equipment" },
|
|
8
|
+
{ value: "other", label: "Other" },
|
|
9
|
+
];
|
|
10
|
+
export const allocationModeOptions = [
|
|
11
|
+
{ value: "shared", label: "Shared" },
|
|
12
|
+
{ value: "exclusive", label: "Exclusive" },
|
|
13
|
+
];
|
|
14
|
+
export const assignmentStatusOptions = [
|
|
15
|
+
{ value: "reserved", label: "Reserved" },
|
|
16
|
+
{ value: "assigned", label: "Assigned" },
|
|
17
|
+
{ value: "released", label: "Released" },
|
|
18
|
+
{ value: "cancelled", label: "Cancelled" },
|
|
19
|
+
{ value: "completed", label: "Completed" },
|
|
20
|
+
];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type { UseAllocationOptions } from "./use-allocation.js";
|
|
2
|
+
export { useAllocation } from "./use-allocation.js";
|
|
3
|
+
export type { UseAllocationsOptions } from "./use-allocations.js";
|
|
4
|
+
export { useAllocations } from "./use-allocations.js";
|
|
5
|
+
export type { UseAssignmentOptions } from "./use-assignment.js";
|
|
6
|
+
export { useAssignment } from "./use-assignment.js";
|
|
7
|
+
export type { UseAssignmentsOptions } from "./use-assignments.js";
|
|
8
|
+
export { useAssignments } from "./use-assignments.js";
|
|
9
|
+
export type { UseBookingsOptions } from "./use-bookings.js";
|
|
10
|
+
export { useBookings } from "./use-bookings.js";
|
|
11
|
+
export type { UseCloseoutsOptions } from "./use-closeouts.js";
|
|
12
|
+
export { useCloseouts } from "./use-closeouts.js";
|
|
13
|
+
export type { UsePoolOptions } from "./use-pool.js";
|
|
14
|
+
export { usePool } from "./use-pool.js";
|
|
15
|
+
export type { UsePoolsOptions } from "./use-pools.js";
|
|
16
|
+
export { usePools } from "./use-pools.js";
|
|
17
|
+
export type { UseProductsOptions } from "./use-products.js";
|
|
18
|
+
export { useProducts } from "./use-products.js";
|
|
19
|
+
export type { UseResourceOptions } from "./use-resource.js";
|
|
20
|
+
export { useResource } from "./use-resource.js";
|
|
21
|
+
export type { UseResourcesOptions } from "./use-resources.js";
|
|
22
|
+
export { useResources } from "./use-resources.js";
|
|
23
|
+
export type { UseRulesOptions } from "./use-rules.js";
|
|
24
|
+
export { useRules } from "./use-rules.js";
|
|
25
|
+
export type { UseSlotsOptions } from "./use-slots.js";
|
|
26
|
+
export { useSlots } from "./use-slots.js";
|
|
27
|
+
export type { UseStartTimesOptions } from "./use-start-times.js";
|
|
28
|
+
export { useStartTimes } from "./use-start-times.js";
|
|
29
|
+
export type { UseSuppliersOptions } from "./use-suppliers.js";
|
|
30
|
+
export { useSuppliers } from "./use-suppliers.js";
|
|
31
|
+
//# 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,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,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;AACpD,YAAY,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { useAllocation } from "./use-allocation.js";
|
|
2
|
+
export { useAllocations } from "./use-allocations.js";
|
|
3
|
+
export { useAssignment } from "./use-assignment.js";
|
|
4
|
+
export { useAssignments } from "./use-assignments.js";
|
|
5
|
+
export { useBookings } from "./use-bookings.js";
|
|
6
|
+
export { useCloseouts } from "./use-closeouts.js";
|
|
7
|
+
export { usePool } from "./use-pool.js";
|
|
8
|
+
export { usePools } from "./use-pools.js";
|
|
9
|
+
export { useProducts } from "./use-products.js";
|
|
10
|
+
export { useResource } from "./use-resource.js";
|
|
11
|
+
export { useResources } from "./use-resources.js";
|
|
12
|
+
export { useRules } from "./use-rules.js";
|
|
13
|
+
export { useSlots } from "./use-slots.js";
|
|
14
|
+
export { useStartTimes } from "./use-start-times.js";
|
|
15
|
+
export { useSuppliers } from "./use-suppliers.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface UseAllocationOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useAllocation(id: string | null | undefined, options?: UseAllocationOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
poolId: string;
|
|
7
|
+
productId: string;
|
|
8
|
+
availabilityRuleId: string | null;
|
|
9
|
+
startTimeId: string | null;
|
|
10
|
+
quantityRequired: number;
|
|
11
|
+
allocationMode: "shared" | "exclusive";
|
|
12
|
+
priority: number;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
}, Error>;
|
|
16
|
+
//# sourceMappingURL=use-allocation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-allocation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-allocation.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,oBAAyB;;;;;;;;;;;UAQ9F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getAllocationQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useAllocation(id, options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getAllocationQueryOptions(client, id, options),
|
|
10
|
+
enabled: enabled && Boolean(id),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ResourceAllocationsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseAllocationsOptions extends ResourceAllocationsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useAllocations(options?: UseAllocationsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
poolId: string;
|
|
9
|
+
productId: string;
|
|
10
|
+
availabilityRuleId: string | null;
|
|
11
|
+
startTimeId: string | null;
|
|
12
|
+
quantityRequired: number;
|
|
13
|
+
allocationMode: "shared" | "exclusive";
|
|
14
|
+
priority: number;
|
|
15
|
+
}[];
|
|
16
|
+
total: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
offset: number;
|
|
19
|
+
}, Error>;
|
|
20
|
+
//# sourceMappingURL=use-allocations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-allocations.d.ts","sourceRoot":"","sources":["../../src/hooks/use-allocations.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AAGtE,MAAM,WAAW,qBAAsB,SAAQ,8BAA8B;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B;;;;;;;;;;;;;;UAQjE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getAllocationsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useAllocations(options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getAllocationsQueryOptions(client, options),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface UseAssignmentOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useAssignment(id: string | null | undefined, options?: UseAssignmentOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
slotId: string;
|
|
7
|
+
poolId: string | null;
|
|
8
|
+
resourceId: string | null;
|
|
9
|
+
bookingId: string | null;
|
|
10
|
+
status: "reserved" | "assigned" | "released" | "cancelled" | "completed";
|
|
11
|
+
assignedBy: string | null;
|
|
12
|
+
releasedAt: string | null;
|
|
13
|
+
notes: string | null;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
}, Error>;
|
|
17
|
+
//# sourceMappingURL=use-assignment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-assignment.d.ts","sourceRoot":"","sources":["../../src/hooks/use-assignment.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,oBAAyB;;;;;;;;;;;;UAQ9F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getAssignmentQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useAssignment(id, options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getAssignmentQueryOptions(client, id, options),
|
|
10
|
+
enabled: enabled && Boolean(id),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ResourceAssignmentsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseAssignmentsOptions extends ResourceAssignmentsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useAssignments(options?: UseAssignmentsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
slotId: string;
|
|
9
|
+
poolId: string | null;
|
|
10
|
+
resourceId: string | null;
|
|
11
|
+
bookingId: string | null;
|
|
12
|
+
status: "reserved" | "assigned" | "released" | "cancelled" | "completed";
|
|
13
|
+
assignedBy: string | null;
|
|
14
|
+
releasedAt: string | null;
|
|
15
|
+
notes: string | null;
|
|
16
|
+
}[];
|
|
17
|
+
total: number;
|
|
18
|
+
limit: number;
|
|
19
|
+
offset: number;
|
|
20
|
+
}, Error>;
|
|
21
|
+
//# sourceMappingURL=use-assignments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-assignments.d.ts","sourceRoot":"","sources":["../../src/hooks/use-assignments.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AAGtE,MAAM,WAAW,qBAAsB,SAAQ,8BAA8B;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B;;;;;;;;;;;;;;;UAQjE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getAssignmentsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useAssignments(options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getAssignmentsQueryOptions(client, options),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PaginationFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseBookingsOptions extends PaginationFilters {
|
|
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,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAGzD,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;UAQ3D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getBookingsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useBookings(options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getBookingsQueryOptions(client, options),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResourceCloseoutsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseCloseoutsOptions extends ResourceCloseoutsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useCloseouts(options?: UseCloseoutsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
resourceId: string;
|
|
9
|
+
dateLocal: string;
|
|
10
|
+
startsAt: string | null;
|
|
11
|
+
endsAt: string | null;
|
|
12
|
+
reason: string | null;
|
|
13
|
+
createdBy: string | null;
|
|
14
|
+
}[];
|
|
15
|
+
total: number;
|
|
16
|
+
limit: number;
|
|
17
|
+
offset: number;
|
|
18
|
+
}, Error>;
|
|
19
|
+
//# 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,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAGpE,MAAM,WAAW,mBAAoB,SAAQ,4BAA4B;IACvE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;UAQ7D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getCloseoutsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useCloseouts(options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getCloseoutsQueryOptions(client, options),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface UsePoolOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function usePool(id: string | null | undefined, options?: UsePoolOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
productId: string | null;
|
|
7
|
+
kind: "guide" | "vehicle" | "room" | "boat" | "equipment" | "other";
|
|
8
|
+
name: string;
|
|
9
|
+
sharedCapacity: number | null;
|
|
10
|
+
active: boolean;
|
|
11
|
+
notes: string | null;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
}, Error>;
|
|
15
|
+
//# sourceMappingURL=use-pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-pool.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pool.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,cAAmB;;;;;;;;;;UAQlF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getPoolQueryOptions } from "../query-options.js";
|
|
5
|
+
export function usePool(id, options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getPoolQueryOptions(client, id, options),
|
|
10
|
+
enabled: enabled && Boolean(id),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResourcePoolsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UsePoolsOptions extends ResourcePoolsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function usePools(options?: UsePoolsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
productId: string | null;
|
|
9
|
+
kind: "guide" | "vehicle" | "room" | "boat" | "equipment" | "other";
|
|
10
|
+
name: string;
|
|
11
|
+
sharedCapacity: number | null;
|
|
12
|
+
active: boolean;
|
|
13
|
+
notes: string | null;
|
|
14
|
+
}[];
|
|
15
|
+
total: number;
|
|
16
|
+
limit: number;
|
|
17
|
+
offset: number;
|
|
18
|
+
}, Error>;
|
|
19
|
+
//# sourceMappingURL=use-pools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-pools.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pools.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAGhE,MAAM,WAAW,eAAgB,SAAQ,wBAAwB;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,QAAQ,CAAC,OAAO,GAAE,eAAoB;;;;;;;;;;;;;UAQrD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getPoolsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function usePools(options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getPoolsQueryOptions(client, options),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PaginationFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseProductsOptions extends PaginationFilters {
|
|
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,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAGzD,MAAM,WAAW,kBAAmB,SAAQ,iBAAiB;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;UAQ3D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getProductsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useProducts(options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getProductsQueryOptions(client, options),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface UseResourceOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useResource(id: string | null | undefined, options?: UseResourceOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
supplierId: string | null;
|
|
7
|
+
kind: "guide" | "vehicle" | "room" | "boat" | "equipment" | "other";
|
|
8
|
+
name: string;
|
|
9
|
+
code: string | null;
|
|
10
|
+
capacity: number | null;
|
|
11
|
+
active: boolean;
|
|
12
|
+
notes: string | null;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
updatedAt: string;
|
|
15
|
+
}, Error>;
|
|
16
|
+
//# sourceMappingURL=use-resource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-resource.d.ts","sourceRoot":"","sources":["../../src/hooks/use-resource.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,kBAAuB;;;;;;;;;;;UAQ1F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getResourceQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useResource(id, options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getResourceQueryOptions(client, id, options),
|
|
10
|
+
enabled: enabled && Boolean(id),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ResourcesListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseResourcesOptions extends ResourcesListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useResources(options?: UseResourcesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
supplierId: string | null;
|
|
9
|
+
kind: "guide" | "vehicle" | "room" | "boat" | "equipment" | "other";
|
|
10
|
+
name: string;
|
|
11
|
+
code: string | null;
|
|
12
|
+
capacity: number | null;
|
|
13
|
+
active: boolean;
|
|
14
|
+
notes: string | null;
|
|
15
|
+
}[];
|
|
16
|
+
total: number;
|
|
17
|
+
limit: number;
|
|
18
|
+
offset: number;
|
|
19
|
+
}, Error>;
|
|
20
|
+
//# sourceMappingURL=use-resources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-resources.d.ts","sourceRoot":"","sources":["../../src/hooks/use-resources.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;;;;;;;;;;;;;;UAQ7D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantResourcesContext } from "../provider.js";
|
|
4
|
+
import { getResourcesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useResources(options = {}) {
|
|
6
|
+
const client = useVoyantResourcesContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getResourcesQueryOptions(client, options),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|