@voyantjs/facilities-react 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/dist/client.d.ts +14 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +58 -0
  4. package/dist/hooks/index.d.ts +16 -0
  5. package/dist/hooks/index.d.ts.map +1 -0
  6. package/dist/hooks/index.js +15 -0
  7. package/dist/hooks/use-facilities.d.ts +31 -0
  8. package/dist/hooks/use-facilities.d.ts.map +1 -0
  9. package/dist/hooks/use-facilities.js +12 -0
  10. package/dist/hooks/use-facility-feature-mutation.d.ts +37 -0
  11. package/dist/hooks/use-facility-feature-mutation.d.ts.map +1 -0
  12. package/dist/hooks/use-facility-feature-mutation.js +38 -0
  13. package/dist/hooks/use-facility-features.d.ts +21 -0
  14. package/dist/hooks/use-facility-features.d.ts.map +1 -0
  15. package/dist/hooks/use-facility-features.js +12 -0
  16. package/dist/hooks/use-facility-mutation.d.ts +74 -0
  17. package/dist/hooks/use-facility-mutation.d.ts.map +1 -0
  18. package/dist/hooks/use-facility-mutation.js +45 -0
  19. package/dist/hooks/use-facility-operation-schedule-mutation.d.ts +37 -0
  20. package/dist/hooks/use-facility-operation-schedule-mutation.d.ts.map +1 -0
  21. package/dist/hooks/use-facility-operation-schedule-mutation.js +44 -0
  22. package/dist/hooks/use-facility-operation-schedules.d.ts +21 -0
  23. package/dist/hooks/use-facility-operation-schedules.d.ts.map +1 -0
  24. package/dist/hooks/use-facility-operation-schedules.js +12 -0
  25. package/dist/hooks/use-facility.d.ts +25 -0
  26. package/dist/hooks/use-facility.d.ts.map +1 -0
  27. package/dist/hooks/use-facility.js +12 -0
  28. package/dist/hooks/use-properties.d.ts +23 -0
  29. package/dist/hooks/use-properties.d.ts.map +1 -0
  30. package/dist/hooks/use-properties.js +12 -0
  31. package/dist/hooks/use-property-group-member-mutation.d.ts +41 -0
  32. package/dist/hooks/use-property-group-member-mutation.d.ts.map +1 -0
  33. package/dist/hooks/use-property-group-member-mutation.js +38 -0
  34. package/dist/hooks/use-property-group-members.d.ts +20 -0
  35. package/dist/hooks/use-property-group-members.d.ts.map +1 -0
  36. package/dist/hooks/use-property-group-members.js +12 -0
  37. package/dist/hooks/use-property-group-mutation.d.ts +50 -0
  38. package/dist/hooks/use-property-group-mutation.d.ts.map +1 -0
  39. package/dist/hooks/use-property-group-mutation.js +39 -0
  40. package/dist/hooks/use-property-group.d.ts +17 -0
  41. package/dist/hooks/use-property-group.d.ts.map +1 -0
  42. package/dist/hooks/use-property-group.js +12 -0
  43. package/dist/hooks/use-property-groups.d.ts +23 -0
  44. package/dist/hooks/use-property-groups.d.ts.map +1 -0
  45. package/dist/hooks/use-property-groups.js +12 -0
  46. package/dist/hooks/use-property-mutation.d.ts +50 -0
  47. package/dist/hooks/use-property-mutation.d.ts.map +1 -0
  48. package/dist/hooks/use-property-mutation.js +40 -0
  49. package/dist/hooks/use-property.d.ts +17 -0
  50. package/dist/hooks/use-property.d.ts.map +1 -0
  51. package/dist/hooks/use-property.js +12 -0
  52. package/dist/index.d.ts +7 -0
  53. package/dist/index.d.ts.map +1 -0
  54. package/dist/index.js +6 -0
  55. package/dist/provider.d.ts +2 -0
  56. package/dist/provider.d.ts.map +1 -0
  57. package/dist/provider.js +1 -0
  58. package/dist/query-keys.d.ts +68 -0
  59. package/dist/query-keys.d.ts.map +1 -0
  60. package/dist/query-keys.js +21 -0
  61. package/dist/query-options.d.ts +808 -0
  62. package/dist/query-options.d.ts.map +1 -0
  63. package/dist/query-options.js +126 -0
  64. package/dist/schemas.d.ts +461 -0
  65. package/dist/schemas.d.ts.map +1 -0
  66. package/dist/schemas.js +84 -0
  67. package/package.json +79 -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;AAaD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;CACvB;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAC5C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACvB,OAAO,EAAE,0BAA0B,EACnC,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
package/dist/client.js ADDED
@@ -0,0 +1,58 @@
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
+ const body = await safeJson(response);
37
+ const parsed = schema.safeParse(body);
38
+ if (!parsed.success) {
39
+ throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
40
+ }
41
+ return parsed.data;
42
+ }
43
+ async function safeJson(response) {
44
+ const text = await response.text();
45
+ if (!text)
46
+ return undefined;
47
+ try {
48
+ return JSON.parse(text);
49
+ }
50
+ catch {
51
+ return text;
52
+ }
53
+ }
54
+ function joinUrl(baseUrl, path) {
55
+ const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
56
+ const trimmedPath = path.startsWith("/") ? path : `/${path}`;
57
+ return `${trimmedBase}${trimmedPath}`;
58
+ }
@@ -0,0 +1,16 @@
1
+ export * from "./use-facilities.js";
2
+ export * from "./use-facility.js";
3
+ export * from "./use-facility-feature-mutation.js";
4
+ export * from "./use-facility-features.js";
5
+ export * from "./use-facility-mutation.js";
6
+ export * from "./use-facility-operation-schedule-mutation.js";
7
+ export * from "./use-facility-operation-schedules.js";
8
+ export * from "./use-properties.js";
9
+ export * from "./use-property.js";
10
+ export * from "./use-property-group.js";
11
+ export * from "./use-property-group-member-mutation.js";
12
+ export * from "./use-property-group-members.js";
13
+ export * from "./use-property-group-mutation.js";
14
+ export * from "./use-property-groups.js";
15
+ export * from "./use-property-mutation.js";
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oCAAoC,CAAA;AAClD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,+CAA+C,CAAA;AAC7D,cAAc,uCAAuC,CAAA;AACrD,cAAc,qBAAqB,CAAA;AACnC,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,yCAAyC,CAAA;AACvD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,kCAAkC,CAAA;AAChD,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA"}
@@ -0,0 +1,15 @@
1
+ export * from "./use-facilities.js";
2
+ export * from "./use-facility.js";
3
+ export * from "./use-facility-feature-mutation.js";
4
+ export * from "./use-facility-features.js";
5
+ export * from "./use-facility-mutation.js";
6
+ export * from "./use-facility-operation-schedule-mutation.js";
7
+ export * from "./use-facility-operation-schedules.js";
8
+ export * from "./use-properties.js";
9
+ export * from "./use-property.js";
10
+ export * from "./use-property-group.js";
11
+ export * from "./use-property-group-member-mutation.js";
12
+ export * from "./use-property-group-members.js";
13
+ export * from "./use-property-group-mutation.js";
14
+ export * from "./use-property-groups.js";
15
+ export * from "./use-property-mutation.js";
@@ -0,0 +1,31 @@
1
+ import type { FacilitiesListFilters } from "../query-keys.js";
2
+ export interface UseFacilitiesOptions extends FacilitiesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useFacilities(options?: UseFacilitiesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ kind: "other" | "hotel" | "resort" | "lodge" | "camp" | "property" | "venue" | "meeting_point" | "transfer_hub" | "airport" | "station" | "marina" | "office" | "attraction" | "restaurant";
8
+ status: "active" | "inactive" | "archived";
9
+ name: string;
10
+ id: string;
11
+ parentFacilityId: string | null;
12
+ ownerType: string | null;
13
+ ownerId: string | null;
14
+ code: string | null;
15
+ description: string | null;
16
+ timezone: string | null;
17
+ addressLine1: string | null;
18
+ addressLine2: string | null;
19
+ city: string | null;
20
+ region: string | null;
21
+ country: string | null;
22
+ postalCode: string | null;
23
+ latitude: number | null;
24
+ longitude: number | null;
25
+ tags: string[];
26
+ }[];
27
+ total: number;
28
+ limit: number;
29
+ offset: number;
30
+ }, Error>;
31
+ //# sourceMappingURL=use-facilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-facilities.d.ts","sourceRoot":"","sources":["../../src/hooks/use-facilities.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAG7D,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;UAQ/D"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFacilitiesContext } from "../provider.js";
4
+ import { getFacilitiesQueryOptions } from "../query-options.js";
5
+ export function useFacilities(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getFacilitiesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,37 @@
1
+ import type { insertFacilityFeatureSchema, updateFacilityFeatureSchema } from "@voyantjs/facilities";
2
+ import type { z } from "zod";
3
+ export type CreateFacilityFeatureInput = z.input<typeof insertFacilityFeatureSchema> & {
4
+ facilityId: string;
5
+ };
6
+ export type UpdateFacilityFeatureInput = z.input<typeof updateFacilityFeatureSchema>;
7
+ export declare function useFacilityFeatureMutation(): {
8
+ create: import("@tanstack/react-query").UseMutationResult<{
9
+ category: "amenity" | "accessibility" | "security" | "service" | "policy" | "other";
10
+ name: string;
11
+ highlighted: boolean;
12
+ sortOrder: number;
13
+ id: string;
14
+ facilityId: string;
15
+ code: string | null;
16
+ description: string | null;
17
+ valueText: string | null;
18
+ }, Error, CreateFacilityFeatureInput, unknown>;
19
+ update: import("@tanstack/react-query").UseMutationResult<{
20
+ category: "amenity" | "accessibility" | "security" | "service" | "policy" | "other";
21
+ name: string;
22
+ highlighted: boolean;
23
+ sortOrder: number;
24
+ id: string;
25
+ facilityId: string;
26
+ code: string | null;
27
+ description: string | null;
28
+ valueText: string | null;
29
+ }, Error, {
30
+ id: string;
31
+ input: UpdateFacilityFeatureInput;
32
+ }, unknown>;
33
+ remove: import("@tanstack/react-query").UseMutationResult<{
34
+ success: boolean;
35
+ }, Error, string, unknown>;
36
+ };
37
+ //# sourceMappingURL=use-facility-feature-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-facility-feature-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-facility-feature-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA;AACpG,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,GAAG;IACrF,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAEpF,wBAAgB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;YAqBE,MAAM;eAAS,0BAA0B;;;;;EA8BpF"}
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantFacilitiesContext } from "../provider.js";
5
+ import { facilitiesQueryKeys } from "../query-keys.js";
6
+ import { facilityFeatureSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useFacilityFeatureMutation() {
8
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async ({ facilityId, ...input }) => {
12
+ const { data } = await fetchWithValidation(`/v1/facilities/facilities/${facilityId}/features`, facilityFeatureSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.facilityFeatures() });
17
+ queryClient.setQueryData(facilitiesQueryKeys.facilityFeature(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/facilities/facility-features/${id}`, facilityFeatureSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.facilityFeatures() });
27
+ queryClient.setQueryData(facilitiesQueryKeys.facilityFeature(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/facilities/facility-features/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
32
+ onSuccess: (_data, id) => {
33
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.facilityFeatures() });
34
+ queryClient.removeQueries({ queryKey: facilitiesQueryKeys.facilityFeature(id) });
35
+ },
36
+ });
37
+ return { create, update, remove };
38
+ }
@@ -0,0 +1,21 @@
1
+ import type { FacilityFeaturesListFilters } from "../query-keys.js";
2
+ export interface UseFacilityFeaturesOptions extends FacilityFeaturesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useFacilityFeatures(options: UseFacilityFeaturesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ category: "amenity" | "accessibility" | "security" | "service" | "policy" | "other";
8
+ name: string;
9
+ highlighted: boolean;
10
+ sortOrder: number;
11
+ id: string;
12
+ facilityId: string;
13
+ code: string | null;
14
+ description: string | null;
15
+ valueText: string | null;
16
+ }[];
17
+ total: number;
18
+ limit: number;
19
+ offset: number;
20
+ }, Error>;
21
+ //# sourceMappingURL=use-facility-features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-facility-features.d.ts","sourceRoot":"","sources":["../../src/hooks/use-facility-features.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAGnE,MAAM,WAAW,0BAA2B,SAAQ,2BAA2B;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B;;;;;;;;;;;;;;;UAQtE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFacilitiesContext } from "../provider.js";
4
+ import { getFacilityFeaturesQueryOptions } from "../query-options.js";
5
+ export function useFacilityFeatures(options) {
6
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getFacilityFeaturesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled: enabled && Boolean(filters.facilityId),
11
+ });
12
+ }
@@ -0,0 +1,74 @@
1
+ import type { insertFacilitySchema, updateFacilitySchema } from "@voyantjs/facilities";
2
+ import type { z } from "zod";
3
+ export type CreateFacilityInput = z.input<typeof insertFacilitySchema>;
4
+ export type UpdateFacilityInput = z.input<typeof updateFacilitySchema>;
5
+ export declare function useFacilityMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ kind: "other" | "hotel" | "resort" | "lodge" | "camp" | "property" | "venue" | "meeting_point" | "transfer_hub" | "airport" | "station" | "marina" | "office" | "attraction" | "restaurant";
8
+ status: "active" | "inactive" | "archived";
9
+ name: string;
10
+ id: string;
11
+ parentFacilityId: string | null;
12
+ ownerType: string | null;
13
+ ownerId: string | null;
14
+ code: string | null;
15
+ description: string | null;
16
+ timezone: string | null;
17
+ addressLine1: string | null;
18
+ addressLine2: string | null;
19
+ city: string | null;
20
+ region: string | null;
21
+ country: string | null;
22
+ postalCode: string | null;
23
+ latitude: number | null;
24
+ longitude: number | null;
25
+ tags: string[];
26
+ }, Error, {
27
+ kind: "other" | "hotel" | "resort" | "lodge" | "camp" | "property" | "venue" | "meeting_point" | "transfer_hub" | "airport" | "station" | "marina" | "office" | "attraction" | "restaurant";
28
+ name: string;
29
+ parentFacilityId?: string | null | undefined;
30
+ ownerType?: "other" | "internal" | "supplier" | "organization" | null | undefined;
31
+ ownerId?: string | null | undefined;
32
+ status?: "active" | "inactive" | "archived" | undefined;
33
+ code?: string | null | undefined;
34
+ description?: string | null | undefined;
35
+ timezone?: string | null | undefined;
36
+ addressLine1?: string | null | undefined;
37
+ addressLine2?: string | null | undefined;
38
+ city?: string | null | undefined;
39
+ region?: string | null | undefined;
40
+ country?: string | null | undefined;
41
+ postalCode?: string | null | undefined;
42
+ latitude?: number | null | undefined;
43
+ longitude?: number | null | undefined;
44
+ tags?: string[] | undefined;
45
+ }, unknown>;
46
+ update: import("@tanstack/react-query").UseMutationResult<{
47
+ kind: "other" | "hotel" | "resort" | "lodge" | "camp" | "property" | "venue" | "meeting_point" | "transfer_hub" | "airport" | "station" | "marina" | "office" | "attraction" | "restaurant";
48
+ status: "active" | "inactive" | "archived";
49
+ name: string;
50
+ id: string;
51
+ parentFacilityId: string | null;
52
+ ownerType: string | null;
53
+ ownerId: string | null;
54
+ code: string | null;
55
+ description: string | null;
56
+ timezone: string | null;
57
+ addressLine1: string | null;
58
+ addressLine2: string | null;
59
+ city: string | null;
60
+ region: string | null;
61
+ country: string | null;
62
+ postalCode: string | null;
63
+ latitude: number | null;
64
+ longitude: number | null;
65
+ tags: string[];
66
+ }, Error, {
67
+ id: string;
68
+ input: UpdateFacilityInput;
69
+ }, unknown>;
70
+ remove: import("@tanstack/react-query").UseMutationResult<{
71
+ success: boolean;
72
+ }, Error, string, unknown>;
73
+ };
74
+ //# sourceMappingURL=use-facility-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-facility-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-facility-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AACtF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEtE,wBAAgB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBS,MAAM;eAAS,mBAAmB;;;;;EAqC7E"}
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantFacilitiesContext } from "../provider.js";
5
+ import { facilitiesQueryKeys } from "../query-keys.js";
6
+ import { facilitySingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useFacilityMutation() {
8
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/facilities/facilities", facilitySingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.facilities() });
17
+ queryClient.setQueryData(facilitiesQueryKeys.facility(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/facilities/facilities/${id}`, facilitySingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.facilities() });
27
+ queryClient.setQueryData(facilitiesQueryKeys.facility(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/facilities/facilities/${id}`, successEnvelope, { baseUrl, fetcher }, {
32
+ method: "DELETE",
33
+ }),
34
+ onSuccess: (_data, id) => {
35
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.facilities() });
36
+ queryClient.removeQueries({ queryKey: facilitiesQueryKeys.facility(id) });
37
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.properties() });
38
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.facilityFeatures() });
39
+ void queryClient.invalidateQueries({
40
+ queryKey: facilitiesQueryKeys.facilityOperationSchedules(),
41
+ });
42
+ },
43
+ });
44
+ return { create, update, remove };
45
+ }
@@ -0,0 +1,37 @@
1
+ import type { insertFacilityOperationScheduleSchema, updateFacilityOperationScheduleSchema } from "@voyantjs/facilities";
2
+ import type { z } from "zod";
3
+ export type CreateFacilityOperationScheduleInput = z.input<typeof insertFacilityOperationScheduleSchema> & {
4
+ facilityId: string;
5
+ };
6
+ export type UpdateFacilityOperationScheduleInput = z.input<typeof updateFacilityOperationScheduleSchema>;
7
+ export declare function useFacilityOperationScheduleMutation(): {
8
+ create: import("@tanstack/react-query").UseMutationResult<{
9
+ closed: boolean;
10
+ id: string;
11
+ facilityId: string;
12
+ dayOfWeek: string | null;
13
+ validFrom: string | null;
14
+ validTo: string | null;
15
+ opensAt: string | null;
16
+ closesAt: string | null;
17
+ notes: string | null;
18
+ }, Error, CreateFacilityOperationScheduleInput, unknown>;
19
+ update: import("@tanstack/react-query").UseMutationResult<{
20
+ closed: boolean;
21
+ id: string;
22
+ facilityId: string;
23
+ dayOfWeek: string | null;
24
+ validFrom: string | null;
25
+ validTo: string | null;
26
+ opensAt: string | null;
27
+ closesAt: string | null;
28
+ notes: string | null;
29
+ }, Error, {
30
+ id: string;
31
+ input: UpdateFacilityOperationScheduleInput;
32
+ }, unknown>;
33
+ remove: import("@tanstack/react-query").UseMutationResult<{
34
+ success: boolean;
35
+ }, Error, string, unknown>;
36
+ };
37
+ //# sourceMappingURL=use-facility-operation-schedule-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-facility-operation-schedule-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-facility-operation-schedule-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qCAAqC,EACrC,qCAAqC,EACtC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,oCAAoC,GAAG,CAAC,CAAC,KAAK,CACxD,OAAO,qCAAqC,CAC7C,GAAG;IACF,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AACD,MAAM,MAAM,oCAAoC,GAAG,CAAC,CAAC,KAAK,CACxD,OAAO,qCAAqC,CAC7C,CAAA;AAED,wBAAgB,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;YA2B1C,MAAM;eACH,oCAAoC;;;;;EAmChD"}
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantFacilitiesContext } from "../provider.js";
5
+ import { facilitiesQueryKeys } from "../query-keys.js";
6
+ import { facilityOperationScheduleSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useFacilityOperationScheduleMutation() {
8
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async ({ facilityId, ...input }) => {
12
+ const { data } = await fetchWithValidation(`/v1/facilities/facilities/${facilityId}/operation-schedules`, facilityOperationScheduleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({
17
+ queryKey: facilitiesQueryKeys.facilityOperationSchedules(),
18
+ });
19
+ queryClient.setQueryData(facilitiesQueryKeys.facilityOperationSchedule(data.id), data);
20
+ },
21
+ });
22
+ const update = useMutation({
23
+ mutationFn: async ({ id, input, }) => {
24
+ const { data } = await fetchWithValidation(`/v1/facilities/facility-operation-schedules/${id}`, facilityOperationScheduleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
25
+ return data;
26
+ },
27
+ onSuccess: (data) => {
28
+ void queryClient.invalidateQueries({
29
+ queryKey: facilitiesQueryKeys.facilityOperationSchedules(),
30
+ });
31
+ queryClient.setQueryData(facilitiesQueryKeys.facilityOperationSchedule(data.id), data);
32
+ },
33
+ });
34
+ const remove = useMutation({
35
+ mutationFn: async (id) => fetchWithValidation(`/v1/facilities/facility-operation-schedules/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
36
+ onSuccess: (_data, id) => {
37
+ void queryClient.invalidateQueries({
38
+ queryKey: facilitiesQueryKeys.facilityOperationSchedules(),
39
+ });
40
+ queryClient.removeQueries({ queryKey: facilitiesQueryKeys.facilityOperationSchedule(id) });
41
+ },
42
+ });
43
+ return { create, update, remove };
44
+ }
@@ -0,0 +1,21 @@
1
+ import type { FacilityOperationSchedulesListFilters } from "../query-keys.js";
2
+ export interface UseFacilityOperationSchedulesOptions extends FacilityOperationSchedulesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useFacilityOperationSchedules(options: UseFacilityOperationSchedulesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ closed: boolean;
8
+ id: string;
9
+ facilityId: string;
10
+ dayOfWeek: string | null;
11
+ validFrom: string | null;
12
+ validTo: string | null;
13
+ opensAt: string | null;
14
+ closesAt: string | null;
15
+ notes: string | null;
16
+ }[];
17
+ total: number;
18
+ limit: number;
19
+ offset: number;
20
+ }, Error>;
21
+ //# sourceMappingURL=use-facility-operation-schedules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-facility-operation-schedules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-facility-operation-schedules.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,kBAAkB,CAAA;AAG7E,MAAM,WAAW,oCACf,SAAQ,qCAAqC;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,oCAAoC;;;;;;;;;;;;;;;UAQ1F"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFacilitiesContext } from "../provider.js";
4
+ import { getFacilityOperationSchedulesQueryOptions } from "../query-options.js";
5
+ export function useFacilityOperationSchedules(options) {
6
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getFacilityOperationSchedulesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled: enabled && Boolean(filters.facilityId),
11
+ });
12
+ }
@@ -0,0 +1,25 @@
1
+ export interface UseFacilityOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useFacility(id: string | null | undefined, options?: UseFacilityOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ kind: "other" | "hotel" | "resort" | "lodge" | "camp" | "property" | "venue" | "meeting_point" | "transfer_hub" | "airport" | "station" | "marina" | "office" | "attraction" | "restaurant";
6
+ status: "active" | "inactive" | "archived";
7
+ name: string;
8
+ id: string;
9
+ parentFacilityId: string | null;
10
+ ownerType: string | null;
11
+ ownerId: string | null;
12
+ code: string | null;
13
+ description: string | null;
14
+ timezone: string | null;
15
+ addressLine1: string | null;
16
+ addressLine2: string | null;
17
+ city: string | null;
18
+ region: string | null;
19
+ country: string | null;
20
+ postalCode: string | null;
21
+ latitude: number | null;
22
+ longitude: number | null;
23
+ tags: string[];
24
+ }, Error>;
25
+ //# sourceMappingURL=use-facility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-facility.d.ts","sourceRoot":"","sources":["../../src/hooks/use-facility.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 { useVoyantFacilitiesContext } from "../provider.js";
4
+ import { getFacilityQueryOptions } from "../query-options.js";
5
+ export function useFacility(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getFacilityQueryOptions({ baseUrl, fetcher }, id ?? ""),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,23 @@
1
+ import type { PropertiesListFilters } from "../query-keys.js";
2
+ export interface UsePropertiesOptions extends PropertiesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useProperties(options?: UsePropertiesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ facilityId: string;
8
+ propertyType: "other" | "hotel" | "resort" | "villa" | "apartment" | "hostel" | "lodge" | "camp";
9
+ id: string;
10
+ brandName: string | null;
11
+ groupName: string | null;
12
+ rating: number | null;
13
+ ratingScale: number | null;
14
+ checkInTime: string | null;
15
+ checkOutTime: string | null;
16
+ policyNotes: string | null;
17
+ amenityNotes: string | null;
18
+ }[];
19
+ total: number;
20
+ limit: number;
21
+ offset: number;
22
+ }, Error>;
23
+ //# sourceMappingURL=use-properties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-properties.d.ts","sourceRoot":"","sources":["../../src/hooks/use-properties.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAG7D,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB;;;;;;;;;;;;;;;;;UAQ/D"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFacilitiesContext } from "../provider.js";
4
+ import { getPropertiesQueryOptions } from "../query-options.js";
5
+ export function useProperties(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getPropertiesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }