@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,41 @@
1
+ import type { insertPropertyGroupMemberSchema, updatePropertyGroupMemberSchema } from "@voyantjs/facilities";
2
+ import type { z } from "zod";
3
+ export type CreatePropertyGroupMemberInput = z.input<typeof insertPropertyGroupMemberSchema>;
4
+ export type UpdatePropertyGroupMemberInput = z.input<typeof updatePropertyGroupMemberSchema>;
5
+ export declare function usePropertyGroupMemberMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ groupId: string;
8
+ propertyId: string;
9
+ membershipRole: "other" | "member" | "flagship" | "managed" | "franchise";
10
+ isPrimary: boolean;
11
+ id: string;
12
+ validFrom: string | null;
13
+ validTo: string | null;
14
+ notes: string | null;
15
+ }, Error, {
16
+ groupId: string;
17
+ propertyId: string;
18
+ membershipRole?: "other" | "member" | "flagship" | "managed" | "franchise" | undefined;
19
+ isPrimary?: boolean | undefined;
20
+ validFrom?: string | null | undefined;
21
+ validTo?: string | null | undefined;
22
+ notes?: string | null | undefined;
23
+ }, unknown>;
24
+ update: import("@tanstack/react-query").UseMutationResult<{
25
+ groupId: string;
26
+ propertyId: string;
27
+ membershipRole: "other" | "member" | "flagship" | "managed" | "franchise";
28
+ isPrimary: boolean;
29
+ id: string;
30
+ validFrom: string | null;
31
+ validTo: string | null;
32
+ notes: string | null;
33
+ }, Error, {
34
+ id: string;
35
+ input: UpdatePropertyGroupMemberInput;
36
+ }, unknown>;
37
+ remove: import("@tanstack/react-query").UseMutationResult<{
38
+ success: boolean;
39
+ }, Error, string, unknown>;
40
+ };
41
+ //# sourceMappingURL=use-property-group-member-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-property-group-member-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property-group-member-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,+BAA+B,EAC/B,+BAA+B,EAChC,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AAC5F,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAA;AAE5F,wBAAgB,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBF,MAAM;eAAS,8BAA8B;;;;;EA8BxF"}
@@ -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 { propertyGroupMemberSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function usePropertyGroupMemberMutation() {
8
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/facilities/property-group-members", propertyGroupMemberSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.propertyGroupMembers() });
17
+ queryClient.setQueryData(facilitiesQueryKeys.propertyGroupMember(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/facilities/property-group-members/${id}`, propertyGroupMemberSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.propertyGroupMembers() });
27
+ queryClient.setQueryData(facilitiesQueryKeys.propertyGroupMember(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/facilities/property-group-members/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
32
+ onSuccess: (_data, id) => {
33
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.propertyGroupMembers() });
34
+ queryClient.removeQueries({ queryKey: facilitiesQueryKeys.propertyGroupMember(id) });
35
+ },
36
+ });
37
+ return { create, update, remove };
38
+ }
@@ -0,0 +1,20 @@
1
+ import type { PropertyGroupMembersListFilters } from "../query-keys.js";
2
+ export interface UsePropertyGroupMembersOptions extends PropertyGroupMembersListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function usePropertyGroupMembers(options: UsePropertyGroupMembersOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ groupId: string;
8
+ propertyId: string;
9
+ membershipRole: "other" | "member" | "flagship" | "managed" | "franchise";
10
+ isPrimary: boolean;
11
+ id: string;
12
+ validFrom: string | null;
13
+ validTo: string | null;
14
+ notes: string | null;
15
+ }[];
16
+ total: number;
17
+ limit: number;
18
+ offset: number;
19
+ }, Error>;
20
+ //# sourceMappingURL=use-property-group-members.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-property-group-members.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property-group-members.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAA;AAGvE,MAAM,WAAW,8BAA+B,SAAQ,+BAA+B;IACrF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,8BAA8B;;;;;;;;;;;;;;UAQ9E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFacilitiesContext } from "../provider.js";
4
+ import { getPropertyGroupMembersQueryOptions } from "../query-options.js";
5
+ export function usePropertyGroupMembers(options) {
6
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getPropertyGroupMembersQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled: enabled && Boolean(filters.groupId),
11
+ });
12
+ }
@@ -0,0 +1,50 @@
1
+ import type { insertPropertyGroupSchema, updatePropertyGroupSchema } from "@voyantjs/facilities";
2
+ import type { z } from "zod";
3
+ export type CreatePropertyGroupInput = z.input<typeof insertPropertyGroupSchema>;
4
+ export type UpdatePropertyGroupInput = z.input<typeof updatePropertyGroupSchema>;
5
+ export declare function usePropertyGroupMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ groupType: "other" | "chain" | "brand" | "management_company" | "collection" | "portfolio" | "cluster";
8
+ status: "active" | "inactive" | "archived";
9
+ name: string;
10
+ id: string;
11
+ parentGroupId: string | null;
12
+ code: string | null;
13
+ brandName: string | null;
14
+ legalName: string | null;
15
+ website: string | null;
16
+ notes: string | null;
17
+ metadata?: Record<string, unknown> | null | undefined;
18
+ }, Error, {
19
+ name: string;
20
+ parentGroupId?: string | null | undefined;
21
+ groupType?: "other" | "chain" | "brand" | "management_company" | "collection" | "portfolio" | "cluster" | undefined;
22
+ status?: "active" | "inactive" | "archived" | undefined;
23
+ code?: string | null | undefined;
24
+ brandName?: string | null | undefined;
25
+ legalName?: string | null | undefined;
26
+ website?: string | null | undefined;
27
+ notes?: string | null | undefined;
28
+ metadata?: Record<string, unknown> | null | undefined;
29
+ }, unknown>;
30
+ update: import("@tanstack/react-query").UseMutationResult<{
31
+ groupType: "other" | "chain" | "brand" | "management_company" | "collection" | "portfolio" | "cluster";
32
+ status: "active" | "inactive" | "archived";
33
+ name: string;
34
+ id: string;
35
+ parentGroupId: string | null;
36
+ code: string | null;
37
+ brandName: string | null;
38
+ legalName: string | null;
39
+ website: string | null;
40
+ notes: string | null;
41
+ metadata?: Record<string, unknown> | null | undefined;
42
+ }, Error, {
43
+ id: string;
44
+ input: UpdatePropertyGroupInput;
45
+ }, unknown>;
46
+ remove: import("@tanstack/react-query").UseMutationResult<{
47
+ success: boolean;
48
+ }, Error, string, unknown>;
49
+ };
50
+ //# sourceMappingURL=use-property-group-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-property-group-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property-group-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChG,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAChF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAEhF,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBI,MAAM;eAAS,wBAAwB;;;;;EA+BlF"}
@@ -0,0 +1,39 @@
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 { propertyGroupSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function usePropertyGroupMutation() {
8
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/facilities/property-groups", propertyGroupSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.propertyGroups() });
17
+ queryClient.setQueryData(facilitiesQueryKeys.propertyGroup(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/facilities/property-groups/${id}`, propertyGroupSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.propertyGroups() });
27
+ queryClient.setQueryData(facilitiesQueryKeys.propertyGroup(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/facilities/property-groups/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
32
+ onSuccess: (_data, id) => {
33
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.propertyGroups() });
34
+ queryClient.removeQueries({ queryKey: facilitiesQueryKeys.propertyGroup(id) });
35
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.propertyGroupMembers() });
36
+ },
37
+ });
38
+ return { create, update, remove };
39
+ }
@@ -0,0 +1,17 @@
1
+ export interface UsePropertyGroupOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function usePropertyGroup(id: string | null | undefined, options?: UsePropertyGroupOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ groupType: "other" | "chain" | "brand" | "management_company" | "collection" | "portfolio" | "cluster";
6
+ status: "active" | "inactive" | "archived";
7
+ name: string;
8
+ id: string;
9
+ parentGroupId: string | null;
10
+ code: string | null;
11
+ brandName: string | null;
12
+ legalName: string | null;
13
+ website: string | null;
14
+ notes: string | null;
15
+ metadata?: Record<string, unknown> | null | undefined;
16
+ }, Error>;
17
+ //# sourceMappingURL=use-property-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-property-group.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property-group.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,GAAE,uBAA4B;;;;;;;;;;;;UAStC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFacilitiesContext } from "../provider.js";
4
+ import { getPropertyGroupQueryOptions } from "../query-options.js";
5
+ export function usePropertyGroup(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getPropertyGroupQueryOptions({ baseUrl, fetcher }, id ?? ""),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,23 @@
1
+ import type { PropertyGroupsListFilters } from "../query-keys.js";
2
+ export interface UsePropertyGroupsOptions extends PropertyGroupsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function usePropertyGroups(options?: UsePropertyGroupsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ groupType: "other" | "chain" | "brand" | "management_company" | "collection" | "portfolio" | "cluster";
8
+ status: "active" | "inactive" | "archived";
9
+ name: string;
10
+ id: string;
11
+ parentGroupId: string | null;
12
+ code: string | null;
13
+ brandName: string | null;
14
+ legalName: string | null;
15
+ website: string | null;
16
+ notes: string | null;
17
+ metadata?: Record<string, unknown> | null | undefined;
18
+ }[];
19
+ total: number;
20
+ limit: number;
21
+ offset: number;
22
+ }, Error>;
23
+ //# sourceMappingURL=use-property-groups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-property-groups.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property-groups.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAGjE,MAAM,WAAW,wBAAyB,SAAQ,yBAAyB;IACzE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B;;;;;;;;;;;;;;;;;UAQvE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantFacilitiesContext } from "../provider.js";
4
+ import { getPropertyGroupsQueryOptions } from "../query-options.js";
5
+ export function usePropertyGroups(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getPropertyGroupsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,50 @@
1
+ import type { insertPropertySchema, updatePropertySchema } from "@voyantjs/facilities";
2
+ import type { z } from "zod";
3
+ export type CreatePropertyInput = z.input<typeof insertPropertySchema>;
4
+ export type UpdatePropertyInput = z.input<typeof updatePropertySchema>;
5
+ export declare function usePropertyMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
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
+ }, Error, {
19
+ facilityId: string;
20
+ propertyType?: "other" | "hotel" | "resort" | "villa" | "apartment" | "hostel" | "lodge" | "camp" | undefined;
21
+ brandName?: string | null | undefined;
22
+ groupName?: string | null | undefined;
23
+ rating?: number | null | undefined;
24
+ ratingScale?: number | null | undefined;
25
+ checkInTime?: string | null | undefined;
26
+ checkOutTime?: string | null | undefined;
27
+ policyNotes?: string | null | undefined;
28
+ amenityNotes?: string | null | undefined;
29
+ }, unknown>;
30
+ update: import("@tanstack/react-query").UseMutationResult<{
31
+ facilityId: string;
32
+ propertyType: "other" | "hotel" | "resort" | "villa" | "apartment" | "hostel" | "lodge" | "camp";
33
+ id: string;
34
+ brandName: string | null;
35
+ groupName: string | null;
36
+ rating: number | null;
37
+ ratingScale: number | null;
38
+ checkInTime: string | null;
39
+ checkOutTime: string | null;
40
+ policyNotes: string | null;
41
+ amenityNotes: string | null;
42
+ }, Error, {
43
+ id: string;
44
+ input: UpdatePropertyInput;
45
+ }, unknown>;
46
+ remove: import("@tanstack/react-query").UseMutationResult<{
47
+ success: boolean;
48
+ }, Error, string, unknown>;
49
+ };
50
+ //# sourceMappingURL=use-property-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-property-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property-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;;;;;EAgC7E"}
@@ -0,0 +1,40 @@
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 { propertySingleResponse, successEnvelope } from "../schemas.js";
7
+ export function usePropertyMutation() {
8
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/facilities/properties", propertySingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.properties() });
17
+ queryClient.setQueryData(facilitiesQueryKeys.property(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/facilities/properties/${id}`, propertySingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.properties() });
27
+ queryClient.setQueryData(facilitiesQueryKeys.property(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/facilities/properties/${id}`, successEnvelope, { baseUrl, fetcher }, {
32
+ method: "DELETE",
33
+ }),
34
+ onSuccess: (_data, id) => {
35
+ void queryClient.invalidateQueries({ queryKey: facilitiesQueryKeys.properties() });
36
+ queryClient.removeQueries({ queryKey: facilitiesQueryKeys.property(id) });
37
+ },
38
+ });
39
+ return { create, update, remove };
40
+ }
@@ -0,0 +1,17 @@
1
+ export interface UsePropertyOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useProperty(id: string | null | undefined, options?: UsePropertyOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ facilityId: string;
6
+ propertyType: "other" | "hotel" | "resort" | "villa" | "apartment" | "hostel" | "lodge" | "camp";
7
+ id: string;
8
+ brandName: string | null;
9
+ groupName: string | null;
10
+ rating: number | null;
11
+ ratingScale: number | null;
12
+ checkInTime: string | null;
13
+ checkOutTime: string | null;
14
+ policyNotes: string | null;
15
+ amenityNotes: string | null;
16
+ }, Error>;
17
+ //# sourceMappingURL=use-property.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-property.d.ts","sourceRoot":"","sources":["../../src/hooks/use-property.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 { getPropertyQueryOptions } from "../query-options.js";
5
+ export function useProperty(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantFacilitiesContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getPropertyQueryOptions({ baseUrl, fetcher }, id ?? ""),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,7 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantFacilitiesContext, type VoyantFacilitiesContextValue, VoyantFacilitiesProvider, type VoyantFacilitiesProviderProps, } from "./provider.js";
4
+ export { type FacilitiesListFilters, type FacilityFeaturesListFilters, type FacilityOperationSchedulesListFilters, facilitiesQueryKeys, type PropertiesListFilters, type PropertyGroupMembersListFilters, type PropertyGroupsListFilters, } from "./query-keys.js";
5
+ export { getFacilitiesQueryOptions, getFacilityFeatureQueryOptions, getFacilityFeaturesQueryOptions, getFacilityOperationScheduleQueryOptions, getFacilityOperationSchedulesQueryOptions, getFacilityQueryOptions, getPropertiesQueryOptions, getPropertyGroupMemberQueryOptions, getPropertyGroupMembersQueryOptions, getPropertyGroupQueryOptions, getPropertyGroupsQueryOptions, getPropertyQueryOptions, } from "./query-options.js";
6
+ export * from "./schemas.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,0BAA0B,EAC1B,KAAK,4BAA4B,EACjC,wBAAwB,EACxB,KAAK,6BAA6B,GACnC,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,qCAAqC,EAC1C,mBAAmB,EACnB,KAAK,qBAAqB,EAC1B,KAAK,+BAA+B,EACpC,KAAK,yBAAyB,GAC/B,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,yBAAyB,EACzB,8BAA8B,EAC9B,+BAA+B,EAC/B,wCAAwC,EACxC,yCAAyC,EACzC,uBAAuB,EACvB,yBAAyB,EACzB,kCAAkC,EAClC,mCAAmC,EACnC,4BAA4B,EAC5B,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantFacilitiesContext, VoyantFacilitiesProvider, } from "./provider.js";
4
+ export { facilitiesQueryKeys, } from "./query-keys.js";
5
+ export { getFacilitiesQueryOptions, getFacilityFeatureQueryOptions, getFacilityFeaturesQueryOptions, getFacilityOperationScheduleQueryOptions, getFacilityOperationSchedulesQueryOptions, getFacilityQueryOptions, getPropertiesQueryOptions, getPropertyGroupMemberQueryOptions, getPropertyGroupMembersQueryOptions, getPropertyGroupQueryOptions, getPropertyGroupsQueryOptions, getPropertyQueryOptions, } from "./query-options.js";
6
+ export * from "./schemas.js";
@@ -0,0 +1,2 @@
1
+ export { useVoyantReactContext as useVoyantFacilitiesContext, type VoyantReactContextValue as VoyantFacilitiesContextValue, VoyantReactProvider as VoyantFacilitiesProvider, type VoyantReactProviderProps as VoyantFacilitiesProviderProps, } 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,0BAA0B,EACnD,KAAK,uBAAuB,IAAI,4BAA4B,EAC5D,mBAAmB,IAAI,wBAAwB,EAC/C,KAAK,wBAAwB,IAAI,6BAA6B,GAC/D,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1 @@
1
+ export { useVoyantReactContext as useVoyantFacilitiesContext, VoyantReactProvider as VoyantFacilitiesProvider, } from "@voyantjs/react";
@@ -0,0 +1,68 @@
1
+ export interface FacilitiesListFilters {
2
+ search?: string | undefined;
3
+ kind?: string | undefined;
4
+ status?: string | undefined;
5
+ ownerType?: string | undefined;
6
+ ownerId?: string | undefined;
7
+ parentFacilityId?: string | undefined;
8
+ country?: string | undefined;
9
+ limit?: number | undefined;
10
+ offset?: number | undefined;
11
+ }
12
+ export interface FacilityFeaturesListFilters {
13
+ facilityId?: string | undefined;
14
+ category?: string | undefined;
15
+ limit?: number | undefined;
16
+ offset?: number | undefined;
17
+ }
18
+ export interface FacilityOperationSchedulesListFilters {
19
+ facilityId?: string | undefined;
20
+ dayOfWeek?: string | undefined;
21
+ limit?: number | undefined;
22
+ offset?: number | undefined;
23
+ }
24
+ export interface PropertiesListFilters {
25
+ facilityId?: string | undefined;
26
+ propertyType?: string | undefined;
27
+ groupName?: string | undefined;
28
+ search?: string | undefined;
29
+ limit?: number | undefined;
30
+ offset?: number | undefined;
31
+ }
32
+ export interface PropertyGroupsListFilters {
33
+ parentGroupId?: string | undefined;
34
+ groupType?: string | undefined;
35
+ status?: string | undefined;
36
+ search?: string | undefined;
37
+ limit?: number | undefined;
38
+ offset?: number | undefined;
39
+ }
40
+ export interface PropertyGroupMembersListFilters {
41
+ groupId?: string | undefined;
42
+ propertyId?: string | undefined;
43
+ membershipRole?: string | undefined;
44
+ limit?: number | undefined;
45
+ offset?: number | undefined;
46
+ }
47
+ export declare const facilitiesQueryKeys: {
48
+ all: readonly ["facilities"];
49
+ facilities: () => readonly ["facilities", "facilities"];
50
+ facilitiesList: (filters: FacilitiesListFilters) => readonly ["facilities", "facilities", FacilitiesListFilters];
51
+ facility: (id: string) => readonly ["facilities", "facilities", string];
52
+ facilityFeatures: () => readonly ["facilities", "facility-features"];
53
+ facilityFeaturesList: (filters: FacilityFeaturesListFilters) => readonly ["facilities", "facility-features", FacilityFeaturesListFilters];
54
+ facilityFeature: (id: string) => readonly ["facilities", "facility-features", string];
55
+ facilityOperationSchedules: () => readonly ["facilities", "facility-operation-schedules"];
56
+ facilityOperationSchedulesList: (filters: FacilityOperationSchedulesListFilters) => readonly ["facilities", "facility-operation-schedules", FacilityOperationSchedulesListFilters];
57
+ facilityOperationSchedule: (id: string) => readonly ["facilities", "facility-operation-schedules", string];
58
+ properties: () => readonly ["facilities", "properties"];
59
+ propertiesList: (filters: PropertiesListFilters) => readonly ["facilities", "properties", PropertiesListFilters];
60
+ property: (id: string) => readonly ["facilities", "properties", string];
61
+ propertyGroups: () => readonly ["facilities", "property-groups"];
62
+ propertyGroupsList: (filters: PropertyGroupsListFilters) => readonly ["facilities", "property-groups", PropertyGroupsListFilters];
63
+ propertyGroup: (id: string) => readonly ["facilities", "property-groups", string];
64
+ propertyGroupMembers: () => readonly ["facilities", "property-group-members"];
65
+ propertyGroupMembersList: (filters: PropertyGroupMembersListFilters) => readonly ["facilities", "property-group-members", PropertyGroupMembersListFilters];
66
+ propertyGroupMember: (id: string) => readonly ["facilities", "property-group-members", string];
67
+ };
68
+ //# 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,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,2BAA2B;IAC1C,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,qCAAqC;IACpD,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,yBAAyB;IACxC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,+BAA+B;IAC9C,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,eAAO,MAAM,mBAAmB;;;8BAGJ,qBAAqB;mBAEhC,MAAM;;oCAEW,2BAA2B;0BAErC,MAAM;;8CAGc,qCAAqC;oCAE/C,MAAM;;8BAGZ,qBAAqB;mBAEhC,MAAM;;kCAES,yBAAyB;wBAEnC,MAAM;;wCAEU,+BAA+B;8BAEzC,MAAM;CACjC,CAAA"}
@@ -0,0 +1,21 @@
1
+ export const facilitiesQueryKeys = {
2
+ all: ["facilities"],
3
+ facilities: () => [...facilitiesQueryKeys.all, "facilities"],
4
+ facilitiesList: (filters) => [...facilitiesQueryKeys.facilities(), filters],
5
+ facility: (id) => [...facilitiesQueryKeys.facilities(), id],
6
+ facilityFeatures: () => [...facilitiesQueryKeys.all, "facility-features"],
7
+ facilityFeaturesList: (filters) => [...facilitiesQueryKeys.facilityFeatures(), filters],
8
+ facilityFeature: (id) => [...facilitiesQueryKeys.facilityFeatures(), id],
9
+ facilityOperationSchedules: () => [...facilitiesQueryKeys.all, "facility-operation-schedules"],
10
+ facilityOperationSchedulesList: (filters) => [...facilitiesQueryKeys.facilityOperationSchedules(), filters],
11
+ facilityOperationSchedule: (id) => [...facilitiesQueryKeys.facilityOperationSchedules(), id],
12
+ properties: () => [...facilitiesQueryKeys.all, "properties"],
13
+ propertiesList: (filters) => [...facilitiesQueryKeys.properties(), filters],
14
+ property: (id) => [...facilitiesQueryKeys.properties(), id],
15
+ propertyGroups: () => [...facilitiesQueryKeys.all, "property-groups"],
16
+ propertyGroupsList: (filters) => [...facilitiesQueryKeys.propertyGroups(), filters],
17
+ propertyGroup: (id) => [...facilitiesQueryKeys.propertyGroups(), id],
18
+ propertyGroupMembers: () => [...facilitiesQueryKeys.all, "property-group-members"],
19
+ propertyGroupMembersList: (filters) => [...facilitiesQueryKeys.propertyGroupMembers(), filters],
20
+ propertyGroupMember: (id) => [...facilitiesQueryKeys.propertyGroupMembers(), id],
21
+ };